Edgewall Software

Ticket #2240: escape_shref.patch

File escape_shref.patch, 2.9 KB (added by cboos, 3 years ago)

Use "!" before a TracLinks for escaping the link (second version, small fix)

  • trac/wiki/tests/wiki-tests.txt

     
    564564<a class="ext-link" href="rfc-2396.compatible://link"><span class="icon"></span>RFC 2396</a> 
    565565</p> 
    566566============================== 
     567!Test:[[BR]] There should be a line break 
     568 
     569!Change:[10] There should be a link to changeset [10] 
     570 
     571Other !test:'''bold text''' is not bold 
     572------------------------------ 
     573<p> 
     574Test:<br /> There should be a line break 
     575</p> 
     576<p> 
     577Change:<a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a> There should be a link to changeset <a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a> 
     578</p> 
     579<p> 
     580Other test:<strong>bold text</strong> is not bold 
     581</p> 
     582============================== 
     583![Test:[[BR]] There should be a line break] 
     584 
     585![Change:[10] There should be a link to changeset [10]] 
     586 
     587Other ![test:'''bold text''' is not bold] 
     588------------------------------ 
     589<p> 
     590[Test:<br /> There should be a line break] 
     591</p> 
     592<p> 
     593[Change:<a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a> There should be a link to changeset <a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a>] 
     594</p> 
     595<p> 
     596Other [test:<strong>bold text</strong> is not bold] 
     597</p> 
     598============================== 
    567599= ça marche! = 
    568600------------------------------ 
    569601<h1 id="çamarche">ça marche!</h1> 
  • trac/wiki/formatter.py

     
    147147                  r"(?P<inlinecode2>!?%s(?P<inline2>.*?)%s)" % (INLINE_TOKEN, 
    148148                                                                INLINE_TOKEN), 
    149149                  r"(?P<htmlescapeentity>!?&#\d+;)"] 
    150     _post_rules = [(r"(?P<shref>!?((?P<sns>%s):" % LINK_SCHEME + 
     150    _post_rules = [(r"(?P<escapehref>!\[?%s:)" % LINK_SCHEME), 
     151                   (r"(?P<shref>(?P<sns>%s):" % LINK_SCHEME + 
    151152                    r"(?P<stgt>'[^']+'|\"[^\"]+\"|" 
    152                     r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])*[^|'~_\.,& \)])))"), 
    153                    (r"(?P<lhref>!?\[(?:(?P<lns>%s):" % LINK_SCHEME + 
     153                    r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])*[^|'~_\.,& \)]))"), 
     154                   (r"(?P<lhref>\[(?:(?P<lns>%s):" % LINK_SCHEME + 
    154155                    r"(?P<ltgt>'[^']+'|\"[^\"]+\"|[^\] ]*)" 
    155156                    r"|(?P<rel>[/.][^ [\]]*))" 
    156157                    r"(?: (?P<label>'[^']+'|\"[^\"]+\"|[^\]]+))?\])"), 
     
    247248            self.open_tag(*italic) 
    248249        return tmp 
    249250 
     251    def _escapehref_formatter(self, match, fullmatch): 
     252        return match[1:] 
     253 
    250254    def _shref_formatter(self, match, fullmatch): 
    251255        ns = fullmatch.group('sns') 
    252256        target = fullmatch.group('stgt')