kopia lustrzana https://github.com/simonw/datasette
Handle \r\n correctly in CSS escapes, refs #980
rodzic
c11383e628
commit
5b8b8ae597
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue