Edgewall Software

Ticket #2029: external_link_fix.patch

File external_link_fix.patch, 3.0 KB (added by cboos, 7 years ago)

The initial patch

  • tests/wiki-tests.txt

     
    6161</p> 
    6262============================== 
    6363ticket:1, changeset:1, report:1, source:foo/bar 
     64 
     65Issue [ticket:1], CS[changeset:1], Listing [report:1], File [source:foo/bar] 
    6466------------------------------ 
    6567<p> 
    6668<a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a>, <a class="missing changeset" href="/changeset/1" rel="nofollow">changeset:1</a>, <a class="report" href="/report/1">report:1</a>, <a class="source" href="/browser/foo/bar">source:foo/bar</a> 
    6769</p> 
     70<p> 
     71Issue <a class="missing ticket" href="/ticket/1" rel="nofollow">1</a>, CS<a class="missing changeset" href="/changeset/1" rel="nofollow">1</a>, Listing <a class="report" href="/report/1">1</a>, File <a class="source" href="/browser/foo/bar">foo/bar</a> 
     72</p> 
    6873============================== 
    6974[ticket:1 ticket 1], [changeset:1 changeset 1], [report:1 report 1],  
    7075[source:foo/bar source foo/bar], [http://www.edgewall.com/ edgewall] 
     
    135140wiki:Foo%20Bar wiki:Foo%20Bar#baz 
    136141 
    137142[wiki:Foo%20Bar Foo Bar] [wiki:Foo%20Bar#baz Foo Bar] 
     143 
     144[wiki:Argv "*argv[] versus **argv"] 
    138145------------------------------ 
    139146<p> 
    140147<a class="missing wiki" href="/wiki/WikiStart" rel="nofollow">Foo?</a> <a class="ext-link" href="http://www.edgewall.com/"><span class="icon"></span>Edgewall</a> 
     
    145152<p> 
    146153<a class="missing wiki" href="/wiki/Foo%20Bar" rel="nofollow">Foo Bar?</a> <a class="missing wiki" href="/wiki/Foo%20Bar#baz" rel="nofollow">Foo Bar?</a> 
    147154</p> 
     155<p> 
     156<a class="missing wiki" href="/wiki/Argv" rel="nofollow">*argv[] versus **argv?</a> 
     157</p> 
    148158============================== 
    149159foo (FooBar) 
    150160 
  • formatter.py

     
    155155                   (r"(?P<lhref>!?\[(?:(?P<lns>%s):" % LINK_SCHEME + 
    156156                    r"(?P<ltgt>'[^']+'|\"[^\"]+\"|[^\] ]+)" 
    157157                    r"|(?P<rel>[/.][^ [\]]*))" 
    158                     r"(?: (?P<label>.*?))?\])"), 
     158                    r"(?: (?P<label>'[^']+'|\"[^\"]+\"|[^\]]+))?\])"), 
    159159                   (r"(?P<macro>!?\[\[(?P<macroname>[\w/+-]+)" 
    160160                    r"(\]\]|\((?P<macroargs>.*?)\)\]\]))"), 
    161161                   r"(?P<heading>^\s*(?P<hdepth>=+)\s.*\s(?P=hdepth)\s*$)", 
     
    289289        target = fullmatch.group('ltgt')  
    290290        if target and target[0] in "'\"": 
    291291            target = target[1:-1] 
    292         label = fullmatch.group('label') or target 
     292        label = fullmatch.group('label') 
     293        if not label: 
     294            if target: 
     295                label = target.startswith('//') and ns+':'+target or target 
     296            else: 
     297                label = ns 
     298        if label and label[0] in "'\"": 
     299            label = label[1:-1] 
    293300        rel = fullmatch.group('rel') 
    294301        if rel: 
    295302            return self._make_relative_link(rel, label or rel)