# HG changeset patch # User Daniel Dourvaris # Date 2019-10-28 08:21:25 # Node ID ca76052a985fd561d26c61da5d923d3373487a05 # Parent b20c076bbbc633da6ea5fd74098d9497028f0fa9 diffs: handle very odd case of binary, corrupted diffs which crashed the diff parser. diff --git a/rhodecode/lib/codeblocks.py b/rhodecode/lib/codeblocks.py --- a/rhodecode/lib/codeblocks.py +++ b/rhodecode/lib/codeblocks.py @@ -168,7 +168,13 @@ def render_tokenstream(tokenstream): if op_tag: result.append(u'<%s>' % op_tag) - escaped_text = html_escape(token_text) + # NOTE(marcink): in some cases of mixed encodings, we might run into + # troubles in the html_escape, in this case we say unicode force on token_text + # that would ensure "correct" data even with the cost of rendered + try: + escaped_text = html_escape(token_text) + except TypeError: + escaped_text = html_escape(safe_unicode(token_text)) # TODO: dan: investigate showing hidden characters like space/nl/tab # escaped_text = escaped_text.replace(' ', ' ')