Escape < and > even if only one of them exists or if found multiple times (#7154)

* Escape < and > even if only one of them exists

In python negative index counts from the end, so without this change or another solution
"example with only < one side" would be converted to 
"example with only < one sid&gt;example with only < one side"

* Escape < and > even if found multiple times
This commit is contained in:
Toom 2022-12-20 21:07:17 +02:00 committed by GitHub
parent 73a1b46bbf
commit 07dc953875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1592,14 +1592,9 @@ def pangoize(message, filename, line):
# Check for unescaped < and >
if "<" in message or ">" in message:
reduced = pangostrip(message)
if "<" in reduced or ">" in reduced:
if ("<" in reduced or ">" in reduced) and not rgb :
if message == reduced: # No pango markup
here = message.find('<')
if message[here:here+4] != "&lt;":
message = message[:here] + "&lt;" + message[here+1:]
here = message.find('>')
if message[here:here+4] != "&gt;":
message = message[:here] + "&gt;" + message[here+1:]
message = message.replace("<", "&lt;").replace(">", "&gt;")
else:
print('"%s", line %d: < or > in pango string requires manual fix.' % (filename, line))
return message