Fix webelem.javascript_escape with U+2028/U+2029.

This commit is contained in:
Florian Bruhin 2015-11-25 10:32:22 +01:00
parent ba4471bb2f
commit 24a71e5c2e
2 changed files with 6 additions and 0 deletions

View File

@ -308,6 +308,9 @@ def javascript_escape(text):
('\n', r'\n'), # We also need to escape newlines for some reason. ('\n', r'\n'), # We also need to escape newlines for some reason.
('\r', r'\r'), ('\r', r'\r'),
('\x00', r'\x00'), ('\x00', r'\x00'),
# http://stackoverflow.com/questions/2965293/
('\u2028', r'\u2028'),
('\u2029', r'\u2029'),
) )
for orig, repl in replacements: for orig, repl in replacements:
text = text.replace(orig, repl) text = text.replace(orig, repl)

View File

@ -587,6 +587,9 @@ class TestJavascriptEscape:
'': '', '': '',
'\x80Ā': '\x80Ā', '\x80Ā': '\x80Ā',
'𐀀\x00𐀀\x00': r'𐀀\x00𐀀\x00', '𐀀\x00𐀀\x00': r'𐀀\x00𐀀\x00',
# http://stackoverflow.com/questions/2965293/
'\u2028': r'\u2028',
'\u2029': r'\u2029',
} }
# Once there was this warning here: # Once there was this warning here: