Commit c9a4ec84 authored by Ahmad Samir's avatar Ahmad Samir Committed by Volker Krause

TemplateParserJob: port QRegExp to QRegularExpression

TemplateParserJobTest::test_makeValidHtml unit test still passes.
parent 804d0e0e
Pipeline #30691 passed with stage
in 58 minutes and 6 seconds
...@@ -1544,16 +1544,19 @@ QString TemplateParserJob::plainTextToHtml(const QString &body) ...@@ -1544,16 +1544,19 @@ QString TemplateParserJob::plainTextToHtml(const QString &body)
void TemplateParserJob::makeValidHtml(QString &body) void TemplateParserJob::makeValidHtml(QString &body)
{ {
QRegExp regEx; if (body.isEmpty()) {
regEx.setMinimal(true); return;
regEx.setPattern(QStringLiteral("<html.*>")); }
QRegularExpression regEx;
if (!body.isEmpty() && !body.contains(regEx)) { regEx.setPattern(QStringLiteral("<html.*?>"));
regEx.setPattern(QStringLiteral("<body.*>")); if (!body.contains(regEx)) {
regEx.setPattern(QStringLiteral("<body.*?>"));
if (!body.contains(regEx)) { if (!body.contains(regEx)) {
body = QLatin1String("<body>") + body + QLatin1String("<br/></body>"); body = QLatin1String("<body>") + body + QLatin1String("<br/></body>");
} }
regEx.setPattern(QStringLiteral("<head.*>")); regEx.setPattern(QStringLiteral("<head.*?>"));
if (!body.contains(regEx)) { if (!body.contains(regEx)) {
body = QLatin1String("<head>") + d->mHeadElement + QLatin1String("</head>") + body; body = QLatin1String("<head>") + d->mHeadElement + QLatin1String("</head>") + body;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment