https://bugs.kde.org/show_bug.cgi?id=518537

            Bug ID: 518537
           Summary: HTML preview shows raw source instead of rendered HTML
    Classification: Applications
           Product: kate
      Version First 25.08.1
       Reported In:
          Platform: Kubuntu
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: part
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Root cause: KPartView::updatePreview() in addons/preview/kpartview.cpp creates
a QTemporaryFile with no file extension (line 211). The webenginepart
(Chrome-based) uses the file extension to detect the MIME
  type of local file:// URLs. With no extension, it cannot identify the content
as text/html and displays it as plain text/source.

  Fix: create the temp file with the MIME-derived extension:

      const QString suffix =
QMimeDatabase().mimeTypeForName(m_document->mimeType()).preferredSuffix();
      const QString tmpl = QDir::tempPath() +
QStringLiteral("/kate-preview-XXXXXX") + (suffix.isEmpty() ? QString() :
QLatin1Char('.') + suffix);
      m_bufferFile = new QTemporaryFile(tmpl, this);

  Tested: confirmed via strace that Kate creates /tmp/kate.XXXXXX (no
extension), and Konqueror (same webenginepart) correctly renders the same file
when opened directly with its .html extension.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to