changeset 2967:e46d0a90556e beta

fixes #612 Double quotes to Single quotes result in 4; to 9; in a visual Diff. Markupsafe.escape method usage was causing some unpredictable behavior
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 27 Oct 2012 14:33:29 +0200
parents 566f0166f21e
children 4abfb1afd9f5
files rhodecode/lib/diffs.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/diffs.py	Sat Oct 27 00:51:08 2012 +0200
+++ b/rhodecode/lib/diffs.py	Sat Oct 27 14:33:29 2012 +0200
@@ -27,7 +27,6 @@
 
 import re
 import difflib
-import markupsafe
 import logging
 
 from itertools import tee, imap
@@ -171,7 +170,9 @@
             self.differ = self._highlight_line_udiff
 
     def escaper(self, string):
-        return markupsafe.escape(string)
+        return string.replace('&', '&amp;')\
+                .replace('<', '&lt;')\
+                .replace('>', '&gt;')
 
     def copy_iterator(self):
         """
@@ -300,6 +301,7 @@
         Parse the diff an return data for the template.
         """
         lineiter = self.lines
+
         files = []
         try:
             line = lineiter.next()
@@ -323,6 +325,7 @@
                 })
 
                 line = lineiter.next()
+
                 while line:
                     match = self._chunk_re.match(line)
                     if not match:
@@ -551,6 +554,7 @@
                     _html.append('''\n\t\t<pre>%(code)s</pre>\n''' % {
                         'code': change['line']
                     })
+
                     _html.append('''\t</td>''')
                     _html.append('''\n</tr>\n''')
         _html.append('''</table>''')