python-pytoml/Reject-invalid-escapes-in-strings.patch
fandehui a49e36dc11 Reject invalid escapes in strings
Fixes `invalid-escape` test.

Signed-off-by: fandehui <fandehui@xfusion.com>
2023-12-29 17:34:58 +08:00

35 lines
1.1 KiB
Diff

From 09b300acf1142fec5de429d3521c09afad0832c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
Date: Sat, 27 Oct 2018 21:57:01 +0200
Subject: [PATCH] Reject invalid escapes in strings
Fixes `invalid-escape` test.
---
pytoml/parser.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pytoml/parser.py b/pytoml/parser.py
index 6d4d483..b4f7646 100644
--- a/pytoml/parser.py
+++ b/pytoml/parser.py
@@ -180,13 +180,13 @@ _ws_re = re.compile(r'[ \t]*')
def _p_ws(s):
s.expect_re(_ws_re)
-_escapes = { 'b': '\b', 'n': '\n', 'r': '\r', 't': '\t', '"': '"', '\'': '\'',
- '\\': '\\', '/': '/', 'f': '\f' }
+_escapes = { 'b': '\b', 'n': '\n', 'r': '\r', 't': '\t', '"': '"',
+ '\\': '\\', 'f': '\f' }
_basicstr_re = re.compile(r'[^"\\\000-\037]*')
_short_uni_re = re.compile(r'u([0-9a-fA-F]{4})')
_long_uni_re = re.compile(r'U([0-9a-fA-F]{8})')
-_escapes_re = re.compile('[bnrt"\'\\\\/f]')
+_escapes_re = re.compile(r'[btnfr\"\\]')
_newline_esc_re = re.compile('\n[ \t\n]*')
def _p_basicstr_content(s, content=_basicstr_re):
res = []
--
2.27.0