Commit a142270d authored by Lorenz Haas's avatar Lorenz Haas Committed by David Schulz

Beautifier: Fix possible endless loop

Change-Id: Ib2f98c2d761ea9abfd6a42ec30cf8318ee7bd575
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 88309188
......@@ -59,9 +59,12 @@ void ConfigurationSyntaxHighlighter::setKeywords(const QStringList &keywords)
if (keywords.isEmpty())
return;
// Check for empty keywords since they can cause an endless loop in highlightBlock().
QStringList pattern;
for (int i = 0, total = keywords.count(); i < total; ++i)
pattern << QRegExp::escape(keywords.at(i));
foreach (const QString &word, keywords) {
if (!word.isEmpty())
pattern << QRegExp::escape(word);
}
m_expressionKeyword.setPattern(QLatin1String("(?:\\s|^)(") + pattern.join(QLatin1String("|"))
+ QLatin1String(")(?=\\s|\\:|\\=|\\,|$)"));
......
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