From 7f27c60c636ff4ea63de11229bb5fe842e4e3ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Alvarez?= Date: Mon, 11 Apr 2011 18:36:37 -0300 Subject: Limit variable names to letters, numbers and underscores. The parser used to allow any non-whitespace character, which could cause problems in practice. For example, you could create a variable with } or = in the name, or a character we may want to use in a syntax extension later. --- src/ruleparser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ruleparser.cpp b/src/ruleparser.cpp index 6b23d94..f4c7387 100644 --- a/src/ruleparser.cpp +++ b/src/ruleparser.cpp @@ -88,6 +88,8 @@ void Rules::load(const QString &filename) // initialize the regexps we will use QRegExp repoLine("create repository\\s+(\\S+)", Qt::CaseInsensitive); + QString varRegex("[A-Za-z0-9_]+"); + QRegExp matchLine("match\\s+(.*)", Qt::CaseInsensitive); QRegExp matchActionLine("action\\s+(\\w+)", Qt::CaseInsensitive); QRegExp matchRepoLine("repository\\s+(\\S+)", Qt::CaseInsensitive); @@ -95,8 +97,8 @@ void Rules::load(const QString &filename) QRegExp matchRevLine("(min|max) revision (\\d+)", Qt::CaseInsensitive); QRegExp matchAnnotateLine("annotated\\s+(\\S+)", Qt::CaseInsensitive); QRegExp matchPrefixLine("prefix\\s+(\\S+)", Qt::CaseInsensitive); - QRegExp declareLine("declare\\s+(\\S+)\\s*=\\s*(\\S+)", Qt::CaseInsensitive); - QRegExp variableLine("\\$\\{(\\S+)\\}", Qt::CaseInsensitive); + QRegExp declareLine("declare\\s+("+varRegex+")\\s*=\\s*(\\S+)", Qt::CaseInsensitive); + QRegExp variableLine("\\$\\{("+varRegex+")\\}", Qt::CaseInsensitive); QRegExp includeLine("include\\s+(.*)", Qt::CaseInsensitive); enum { ReadingNone, ReadingRepository, ReadingMatch } state = ReadingNone; -- cgit v1.2.1