Edgewall Software

Ticket #2240 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

leading colon breaks wiki syntax

Reported by: vittorio@… Owned by: cboos
Priority: high Milestone: 0.9
Component: wiki system Version: devel
Severity: major Keywords:
Cc: vittorio@…

Description

A leading colon breaks some (maybe all) wiki syntax.

Some Tests:

Test:[[BR]] There should be a line break

Change:[10] There should be a link to changeset [10]

Other test:'''bold text''' is not bold

Output:

Test:
There should be a line break

Change:[10] There should be a link to [10]

Other test:bold text is not bold

tested using trunk r2385, python 2.3.5, mod_python

Attachments

escape_shref.patch (2.9 kB) - added by cboos 3 years ago.
Use "!" before a TracLinks for escaping the link (second version, small fix)
escape_shref.2.patch (3.0 kB) - added by cboos 3 years ago.
Take two, adding as a special case link:[[BR]] to translate to link:<br /> without the need of "!"

Change History

Changed 3 years ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned

Well, this is the syntax for TracLinks. With the current trunk, the example you gave don't make sense as links, but with InterTrac / InterWiki, they will:

  • with InterTrac, what comes after the ":" is meant to be a shorthand to some object in the system. So Change:[10] would be interpreted as changeset 10 in the project named Change.
  • with InterWiki, what comes after the ":" is simply appended to the URL corresponding to the InterWiki prefix. It's even possible to have multiple colon-separated arguments and have them replaced in arbitrary position in the URL (see #1414). So Test:[[BR]] could be a valid InterWiki link.
  • lastly, test:'''...''' is interpreted as a link to test:'' followed by '...''', because single quotes (or double quotes) are use to quote target with embedded spaces.

That being said, there should be an easy way to escape those constructs.

I would propose to use the "!" prefix before what would otherwise look like a link prefix:

!Test:[[BR]] There should be a line break

!Change:[10] There should be a link to changeset [10]

!Other test:'''bold text''' is not bold

Changed 3 years ago by cboos

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

Changed 3 years ago by cboos

The attachment:escape_shref.patch implements the previous idea, and also enables the escaping of TracLinks with title, e.g.:

![Test:[[BR]] There should be a line break]

![Change:[10] There should be a link to changeset [10]]

Other [test:'''bold text''' is not bold]

Changed 3 years ago by cboos

Careful readers might have caught the two errors in my examples above... Well, I got the unit-tests right, at least :)

Need to work on #454...

Changed 3 years ago by cboos

Take two, adding as a special case link:[[BR]] to translate to link:<br /> without the need of "!"

Changed 3 years ago by cboos

Take three, this time on top of r2399:

  • tests/wiki-tests.txt

     
    357357</p> 
    358358------------------------------ 
    359359============================== 
     360Test:[[BR]] There should be a line break 
     361 
     362Change:[10] There should be a link to changeset [10] 
     363 
     364Other test:'''bold text''' is not bold 
     365------------------------------ 
     366<p> 
     367Test:<br /> There should be a line break 
     368</p> 
     369<p> 
     370Change:<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> 
     371</p> 
     372<p> 
     373Other test:<strong>bold text</strong> is not bold 
     374</p> 
     375------------------------------ 
     376Test:  There should be a line break 
     377 
     378Change:<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> 
     379 
     380Other test:<strong>bold text</strong> is not bold 
     381============================== 
    360382{{{ 
    361383Preformatted text. 
    362384}}} 
  • formatter.py

     
    137137 
    138138    QUOTED_STRING = r"'[^']+'|\"[^\"]+\"" 
    139139 
     140    SHREF_TARGET_FIRST = r"[\w/?!#@]" 
    140141    SHREF_TARGET_MIDDLE = r"(?:\|(?=[^|\s])|&(?!lt;)|[^|&\s])" 
    141     SHREF_TARGET_LAST_CHAR = r"[^|'~_\.,&\s\)\]:?!]" 
     142    SHREF_TARGET_LAST = r"[a-zA-Z0-9/=]" # we don't want "_" 
    142143 
    143144    LHREF_RELATIVE_TARGET = r"[/.][^\s[\]]*" 
    144145 
     
    163164 
    164165    _post_rules = [ 
    165166        # shref corresponds to short TracLinks, i.e. sns:stgt 
    166         r"(?P<shref>((?P<sns>%s):(?P<stgt>%s|%s*%s)))" \ 
     167        r"(?P<shref>((?P<sns>%s):(?P<stgt>%s|%s(?:%s*%s)?)))" \ 
    167168        % (LINK_SCHEME, QUOTED_STRING, 
    168            SHREF_TARGET_MIDDLE, SHREF_TARGET_LAST_CHAR), 
     169           SHREF_TARGET_FIRST, SHREF_TARGET_MIDDLE, SHREF_TARGET_LAST), 
    169170        # lhref corresponds to long TracLinks, i.e. [lns:ltgt label?] 
    170171        r"(?P<lhref>\[(?:(?P<lns>%s):(?P<ltgt>%s|[^\]\s]*)|(?P<rel>%s))" 
    171172        r"(?:\s+(?P<label>%s|[^\]]+))?\])" \ 

For the rational about the SHREF_TARGET_LAST, see related #1153.

Changed 3 years ago by vittorio@…

using trunk r2400 patched with Ticket #1153: shref_fixes_r2399.patch, the three tests in the ticket description do work again! i couldnt find a problem when playing a bit with wiki and this patch.

Changed 3 years ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r2401.

I'll reuse and update the attachment:escape_shref.2.patch for fixing #2251...

Add/Change #2240 (leading colon breaks wiki syntax)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.