mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
wrap output it html document & body
ensure right encoding is set
BUG: 500515
(cherry picked from commit 7ef31a7977)
This commit is contained in:
committed by
Kurt Hindenburg
parent
b301f7145b
commit
193ff3cd4d
@@ -112,6 +112,14 @@ void TerminalCharacterDecoderTest::testHTMLDecoder()
|
||||
decoder->end();
|
||||
delete[] testCharacters;
|
||||
delete decoder;
|
||||
|
||||
// ensure we exported the encoding, bug 500515
|
||||
QVERIFY(outputString.contains(QStringLiteral("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />")));
|
||||
|
||||
// strip HTML document
|
||||
outputString.replace(QRegularExpression(QStringLiteral("^.*<body>\\n"), QRegularExpression::DotMatchesEverythingOption), QString());
|
||||
outputString.replace(QRegularExpression(QStringLiteral("</body>.*$"), QRegularExpression::DotMatchesEverythingOption), QString());
|
||||
|
||||
QCOMPARE(outputString, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,15 @@ void HTMLDecoder::begin(QTextStream *output)
|
||||
{
|
||||
_output = output;
|
||||
|
||||
// open html document & body, ensure right encoding set, bug 500515
|
||||
*_output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||
*_output << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">\n";
|
||||
*_output << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
|
||||
*_output << "<head>\n";
|
||||
*_output << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
|
||||
*_output << "</head>\n";
|
||||
*_output << "<body>\n";
|
||||
|
||||
QString text;
|
||||
openSpan(text, QStringLiteral("font-family:monospace"));
|
||||
*output << text;
|
||||
@@ -43,6 +52,10 @@ void HTMLDecoder::end()
|
||||
closeSpan(text);
|
||||
*_output << text;
|
||||
|
||||
// close body & html document
|
||||
*_output << "</body>\n";
|
||||
*_output << "</html>\n";
|
||||
|
||||
_output = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user