Commits

cboos  committed b03d359

Usage of the "!" prefix in front of a TracLinks escapes it (both `shref` and `lhref` forms). Fixes #2251.

  • Participants
  • Parent commits 37fd9fa
  • Branches trunk

Comments (0)

Files changed (3)

File trac/wiki/formatter.py

         r"(?P<htmlescapeentity>!?&#\d+;)"]
 
     _post_rules = [
+        # escape shref and lhref using ! prefix
+        r"(?P<escapehref>!\[?%s:)" % LINK_SCHEME,
         # shref corresponds to short TracLinks, i.e. sns:stgt
         r"(?P<shref>((?P<sns>%s):(?P<stgt>%s|%s(?:%s*%s)?)))" \
         % (LINK_SCHEME, QUOTED_STRING,
             self.open_tag(*italic)
         return tmp
 
+    def _escapehref_formatter(self, match, fullmatch):
+        return match[1:]
+    
     def _shref_formatter(self, match, fullmatch):
         ns = fullmatch.group('sns')
         target = fullmatch.group('stgt')

File trac/wiki/tests/formatter.py

         try:
             self.assertEquals(self.correct, v)
         except AssertionError, e:
-            raise AssertionError('%s\n%s:%s: for the input '
+            raise AssertionError('%s\n\n%s:%s: for the input '
                                  '(formatter flavor was "%s")' \
                                  % (str(e), self.file, self.line,
                                     formatter.flavor))

File trac/wiki/tests/wiki-tests.txt

 </p>
 ------------------------------
 ==============================
+!ticket:1, !changeset:1, !report:1, !source:foo/bar
+Issue ![ticket:1 number 1], CS![changeset:1], ![foo:bar]
+------------------------------
+<p>
+ticket:1, changeset:1, report:1, source:foo/bar
+Issue [ticket:1 number 1], CS[changeset:1], [foo:bar]
+</p>
+------------------------------
+==============================
 [ticket:1 ticket 1], [changeset:1 changeset 1], [report:1 report 1], 
 [source:foo/bar source foo/bar], [http://www.edgewall.com/ edgewall]
 ------------------------------