Reject invalid escapes in strings

Fixes `invalid-escape` test.
This commit is contained in:
linker99 2023-10-31 19:22:46 +08:00
parent 5857ce352d
commit 9aaea03625
2 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,34 @@
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

View File

@ -2,13 +2,14 @@
Name: python-%{github_name}
Version: 0.1.18
Release: 4
Release: 5
Summary: Parser for TOML
License: MIT
URL: https://github.com/avakar/%{github_name}
Source0: https://github.com/avakar/%{github_name}/archive/v%{version}/%{github_name}-%{version}.tar.gz
Patch0: Add-.vscode-and-.pytest_cache-to-.gitignore.patch
Patch1: Fix-datetime-serialization.patch
Patch2: Reject-invalid-escapes-in-strings.patch
BuildArch: noarch
%global my_description \
@ -62,11 +63,14 @@ BuildRequires: python3-setuptools
%{python3_sitelib}/%{github_name}/
%changelog
* Fri Nov 24 2023 fandehui <fandehui@xfusion.com> - 0.1.18-5
- Fixes `invalid-escape` test.
* Tue Nov 14 2023 fandehui <fandehui@xfusion.com> - 0.1.18-4
- Fix-datetime-serialization.patch
* Fri Nov 3 2023 fandehui <fandehui@xfusion.com> - 0.1.18-3
- Add .vscode and .pytest_cache to .gitignore
- Add .vscode and .pytest_cache to .gitignore
* Tue Dec 3 2019 mengxian <mengxian@huawei.com> - 0.1.18-2
- Package init