mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Handle \r\n correctly in CSS escapes, refs #980
This commit is contained in:
parent
c11383e628
commit
5b8b8ae597
2 changed files with 5 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue