diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2016-04-29 02:28:45 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2016-04-29 02:28:45 +0000 |
commit | a89d65a321cab49fe72b682ba9c916a4c6601226 (patch) | |
tree | 5c40b37bf1dc20fbd3a27137f7426f22cceecda4 /src/pyparsing.py | |
parent | 80a04cf253dbc0abe5aa36c55b350ee38e7a1f21 (diff) | |
download | pyparsing-git-a89d65a321cab49fe72b682ba9c916a4c6601226.tar.gz |
Fixed catastrophic regex backtracking in implementation of the quoted string expressions (dblQuotedString, sglQuotedString, and quotedString)
Diffstat (limited to 'src/pyparsing.py')
-rw-r--r-- | src/pyparsing.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py index 5cc4727..fc6a439 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when """
__version__ = "2.1.2"
-__versionTime__ = "22 Apr 2016 09:25 UTC"
+__versionTime__ = "28 Apr 2016 22:32 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -3693,9 +3693,10 @@ def infixNotation( baseExpr, opList, lpar=Suppress('('), rpar=Suppress(')') ): return ret
operatorPrecedence = infixNotation
-dblQuotedString = Regex(r'"(?:[^"\n\r\\]|(?:"")|(?:\\x[0-9a-fA-F]+)|(?:\\.))*"').setName("string enclosed in double quotes")
-sglQuotedString = Regex(r"'(?:[^'\n\r\\]|(?:'')|(?:\\x[0-9a-fA-F]+)|(?:\\.))*'").setName("string enclosed in single quotes")
-quotedString = Regex(r'''(?:"(?:[^"\n\r\\]|(?:"")|(?:\\x[0-9a-fA-F]+)|(?:\\.))*")|(?:'(?:[^'\n\r\\]|(?:'')|(?:\\x[0-9a-fA-F]+)|(?:\\.))*')''').setName("quotedString using single or double quotes")
+dblQuotedString = Combine(Regex(r'"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*')+'"').setName("string enclosed in double quotes")
+sglQuotedString = Combine(Regex(r"'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*")+"'").setName("string enclosed in single quotes")
+quotedString = Combine(Regex(r'"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*')+'"'|
+ Regex(r"'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*")+"'").setName("quotedString using single or double quotes")
unicodeString = Combine(_L('u') + quotedString.copy()).setName("unicode string literal")
def nestedExpr(opener="(", closer=")", content=None, ignoreExpr=quotedString.copy()):
|