Changeset - 7d0476e1f1dc
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2012-12-11 01:15:30
marcin@python-works.com
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
- regex by \W did split &amp; and other to 3 tokens, and escaping was broken
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/diffs.py
Show inline comments
 
@@ -193,6 +193,9 @@ class DiffProcessor(object):
 
        (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))?
 
    """, re.VERBOSE | re.MULTILINE)
 

	
 
    #used for inline highlighter word split
 
    _token_re = re.compile(r'()(&gt;|&lt;|&amp;|\W+?)')
 

	
 
    def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None):
 
        """
 
        :param diff:   a text in diff format
 
@@ -274,9 +277,8 @@ class DiffProcessor(object):
 
        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 = [], []
0 comments (0 inline, 0 general)