From 1edfcc8f23bb67b981f1bebac469ed8572e032f7 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 28 Aug 2022 13:01:44 +0200 Subject: [PATCH] gui: PreviewGeneratorPlainText: Escape html before working on text We use this semi-HTML mode to highlight words, but if we already have tags in the document this does not work quite well. Thus, escape the string before further processing it --- gui/previewgeneratorplaintext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/previewgeneratorplaintext.cpp b/gui/previewgeneratorplaintext.cpp index c52c82f..d7b4494 100644 --- a/gui/previewgeneratorplaintext.cpp +++ b/gui/previewgeneratorplaintext.cpp @@ -58,6 +58,7 @@ QString PreviewGeneratorPlainText::generatePreviewText(QString content, RenderCo ++i; } + resulText = resulText.toHtmlEscaped(); QString header = "" + fileName + " "; for(QString &word : config.wordsToHighlight) { @@ -112,7 +113,6 @@ QString PreviewGeneratorPlainText::generateLineBasedPreviewText(QTextStream &in, if(containsRegex || contains) { currentSnippet.wordCountMap[word] = currentSnippet.wordCountMap.value(word, 0) + 1; - QString replacementString = "" + word + ""; if(containsRegex) { @@ -132,6 +132,7 @@ QString PreviewGeneratorPlainText::generateLineBasedPreviewText(QTextStream &in, unsigned int lineCount = 0; while(in.readLineInto(¤tLine)) { + currentLine = currentLine.toHtmlEscaped(); ++lineCount; bool matched = false; if(justReadLinesCount > 0)