Handle \r\n correctly in CSS escapes, refs #980

sql-errors
Simon Willison 2020-09-29 12:16:30 -07:00
rodzic c11383e628
commit 5b8b8ae597
2 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -271,7 +271,10 @@ _boring_keyword_re = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
def escape_css_string(s):
return _css_re.sub(lambda m: "\\" + ("{:X}".format(ord(m.group())).zfill(6)), s)
return _css_re.sub(
lambda m: "\\" + ("{:X}".format(ord(m.group())).zfill(6)),
s.replace("\r\n", "\n"),
)
def escape_sqlite(s):

Wyświetl plik

@ -425,6 +425,7 @@ def test_escape_fts(query, expected):
[
("dog", "dog"),
('dateutil_parse("1/2/2020")', r"dateutil_parse(\0000221/2/2020\000022)"),
("this\r\nand\r\nthat", r"this\00000Aand\00000Athat"),
],
)
def test_escape_css_string(input, expected):