Fix unparsing malformed entities, bump v1.10.10

This commit is contained in:
Lonami Exo
2019-12-30 10:57:03 +01:00
parent be8838b5f8
commit d196c89825
6 changed files with 94 additions and 11 deletions

View File

@@ -189,7 +189,7 @@ def unparse(text, entities, delimiters=None, url_fmt=None):
# Otherwise we would end up with malformed text and fail to encode.
# For example of bad input: "Hi \ud83d\ude1c"
# https://en.wikipedia.org/wiki/UTF-16#U+010000_to_U+10FFFF
if '\ud800' <= text[at] <= '\udfff':
while at < len(text) and '\ud800' <= text[at] <= '\udfff':
at += 1
text = text[:at] + what + text[at:]