mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
html_diff: Handle empty differences between empty strings.
`rendered_content` in historical messages may be empty; examining the history of them may thus require diff'ing two empty strings, which itself produces an empty string. Use `lxml.html.fragment_fromstring` to be able to successfully parse these, rather than 500. Part of #19559.
This commit is contained in:
committed by
Alex Vandiver
parent
f6c78a35a4
commit
b02754adec
@@ -6,7 +6,7 @@ from lxml.html.diff import htmldiff
|
||||
|
||||
def highlight_html_differences(s1: str, s2: str, msg_id: Optional[int] = None) -> str:
|
||||
retval = htmldiff(s1, s2)
|
||||
fragment = lxml.html.fromstring(retval)
|
||||
fragment = lxml.html.fragment_fromstring(retval, create_parent=True)
|
||||
|
||||
for elem in fragment.cssselect("del"):
|
||||
elem.tag = "span"
|
||||
|
||||
Reference in New Issue
Block a user