diff options
author | Nicolás Alvarez <nicolas.alvarez@gmail.com> | 2011-04-11 18:36:37 -0300 |
---|---|---|
committer | Nicolás Alvarez <nicolas.alvarez@gmail.com> | 2011-04-11 18:36:37 -0300 |
commit | 7f27c60c636ff4ea63de11229bb5fe842e4e3ca7 (patch) | |
tree | 7479c0ca197314f757bc0ba53d16da48c920a133 /src | |
parent | 9677b1fea3ab82db3e9185439938d9e2380e02d4 (diff) | |
download | svn2git-7f27c60c636ff4ea63de11229bb5fe842e4e3ca7.tar svn2git-7f27c60c636ff4ea63de11229bb5fe842e4e3ca7.tar.gz svn2git-7f27c60c636ff4ea63de11229bb5fe842e4e3ca7.tar.bz2 svn2git-7f27c60c636ff4ea63de11229bb5fe842e4e3ca7.tar.xz svn2git-7f27c60c636ff4ea63de11229bb5fe842e4e3ca7.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ruleparser.cpp | 6 |
1 files 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; |