From a04eac3ffa53cb9eea9ebc46ea67a958f0269220 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Fri, 2 Dec 2016 15:50:38 -0600 Subject: [PATCH] Allow palette names with digits 0-9 Modify the regular expression for palette matching to allow digits (e.g. 0-9) in the name. There seems to be no reason to block them. Document the palette-matching regex. --- src/uisupport/qssparser.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/uisupport/qssparser.cpp b/src/uisupport/qssparser.cpp index 78dc4162..30a8fdd9 100644 --- a/src/uisupport/qssparser.cpp +++ b/src/uisupport/qssparser.cpp @@ -463,7 +463,21 @@ QBrush QssParser::parseBrush(const QString &str, bool *ok) } if (str.startsWith("palette")) { // Palette color role - QRegExp rx("palette\\s*\\(\\s*([a-z-]+)\\s*\\)"); + // Does the palette follow the expected format? For example: + // palette(marker-line) + // palette ( system-color-0f ) + // + // Match the palette marker, grabbing the name inside in case-sensitive manner + // palette\s*\(\s*([a-z-0-9]+)\s*\) + // palette Match the string 'palette' + // \s* Match any amount of whitespace + // \(, \) Match literal '(' or ')' marks + // (...+) Match contents between 1 and unlimited number of times + // [a-z-] Match any character from a-z, case sensitive + // [0-9] Match any digit from 0-9 + // Note that '\' must be escaped as '\\' + // Helpful interactive website for debugging and explaining: https://regex101.com/ + QRegExp rx("palette\\s*\\(\\s*([a-z-0-9]+)\\s*\\)"); if (!rx.exactMatch(str)) { qWarning() << Q_FUNC_INFO << tr("Invalid palette color role specification: %1").arg(str); return QBrush(); -- 2.20.1