Mercurial > kallithea
changeset 3085:7d0476e1f1dc beta
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
- regex by \W did split & and other to 3 tokens, and escaping was broken
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 11 Dec 2012 01:15:30 +0100 |
parents | 2ec4a2a53167 |
children | f9c44f3ed4c6 |
files | rhodecode/lib/diffs.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/diffs.py Tue Dec 11 00:02:23 2012 +0100 +++ b/rhodecode/lib/diffs.py Tue Dec 11 01:15:30 2012 +0100 @@ -193,6 +193,9 @@ (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))? """, re.VERBOSE | re.MULTILINE) + #used for inline highlighter word split + _token_re = re.compile(r'()(>|<|&|\W+?)') + def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None): """ :param diff: a text in diff format @@ -274,9 +277,8 @@ else: old, new = next_, line - oldwords = re.split(r'(\W)', old['line']) - newwords = re.split(r'(\W)', new['line']) - + oldwords = self._token_re.split(old['line']) + newwords = self._token_re.split(new['line']) sequence = difflib.SequenceMatcher(None, oldwords, newwords) oldfragments, newfragments = [], []