aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mparser.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2019-04-28 21:06:36 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-04-28 23:06:36 +0300
commitccc4ce28cc9077d77a0bc9e72b1177eba1be7186 (patch)
tree8ed953d8d9afd62721c88ab3ce6460d85e5b596e /mesonbuild/mparser.py
parent03d34a79f8632bd8d84d06e1f76b2fdba00a9be0 (diff)
downloadmeson-ccc4ce28cc9077d77a0bc9e72b1177eba1be7186.zip
meson-ccc4ce28cc9077d77a0bc9e72b1177eba1be7186.tar.gz
meson-ccc4ce28cc9077d77a0bc9e72b1177eba1be7186.tar.bz2
consistent invalid escape sequence behaviour
* docs: document unrecognized escape sequence behaviour [skip ci] Document that unrecognized escape sequence behaviour is like python, not C. * Don't try to decode invalid hex escape sequences Don't try to decode escape sequences which should contain a sequence of hex digits, but don't, throwing a python exception. These will treated literally instead. * Extend test case to cover invalid escape sequences
Diffstat (limited to 'mesonbuild/mparser.py')
-rw-r--r--mesonbuild/mparser.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index 17783ce..4305a7c 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -21,12 +21,12 @@ from . import mlog
# This is the regex for the supported escape sequences of a regular string
# literal, like 'abc\x00'
ESCAPE_SEQUENCE_SINGLE_RE = re.compile(r'''
- ( \\U........ # 8-digit hex escapes
- | \\u.... # 4-digit hex escapes
- | \\x.. # 2-digit hex escapes
- | \\[0-7]{1,3} # Octal escapes
- | \\N\{[^}]+\} # Unicode characters by name
- | \\[\\'abfnrtv] # Single-character escapes
+ ( \\U[A-Fa-f0-9]{8} # 8-digit hex escapes
+ | \\u[A-Fa-f0-9]{4} # 4-digit hex escapes
+ | \\x[A-Fa-f0-9]{2} # 2-digit hex escapes
+ | \\[0-7]{1,3} # Octal escapes
+ | \\N\{[^}]+\} # Unicode characters by name
+ | \\[\\'abfnrtv] # Single-character escapes
)''', re.UNICODE | re.VERBOSE)
class MesonUnicodeDecodeError(MesonException):