# HG changeset patch # User Daniel Dourvaris # Date 2019-10-28 08:21:25 # Node ID 0f09c1a734e267268097b3229ab8eb3761e4780b # Parent 5bbd362b99b3620f0a45b76cd6bec78aba89f48d 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(' ', ' ')