Opened 19 years ago
Closed 19 years ago
#2240 closed defect (fixed)
leading colon breaks wiki syntax
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | wiki system | Version: | devel |
Severity: | major | Keywords: | |
Cc: | vittorio@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
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 (2)
Change History (8)
comment:1 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 19 years ago
Attachment: | escape_shref.patch added |
---|
Use "!" before a TracLinks for escaping the link (second version, small fix)
comment:2 by , 19 years ago
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]
comment:3 by , 19 years ago
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…
by , 19 years ago
Attachment: | escape_shref.2.patch added |
---|
Take two, adding as a special case link:[[BR]]
to translate to link:<br />
without the need of "!"
comment:4 by , 19 years ago
Take three, this time on top of r2399:
-
tests/wiki-tests.txt
357 357 </p> 358 358 ------------------------------ 359 359 ============================== 360 Test:[[BR]] There should be a line break 361 362 Change:[10] There should be a link to changeset [10] 363 364 Other test:'''bold text''' is not bold 365 ------------------------------ 366 <p> 367 Test:<br /> There should be a line break 368 </p> 369 <p> 370 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> 371 </p> 372 <p> 373 Other test:<strong>bold text</strong> is not bold 374 </p> 375 ------------------------------ 376 Test: There should be a line break 377 378 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> 379 380 Other test:<strong>bold text</strong> is not bold 381 ============================== 360 382 {{{ 361 383 Preformatted text. 362 384 }}} -
formatter.py
137 137 138 138 QUOTED_STRING = r"'[^']+'|\"[^\"]+\"" 139 139 140 SHREF_TARGET_FIRST = r"[\w/?!#@]" 140 141 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 "_" 142 143 143 144 LHREF_RELATIVE_TARGET = r"[/.][^\s[\]]*" 144 145 … … 163 164 164 165 _post_rules = [ 165 166 # 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)?)))" \ 167 168 % (LINK_SCHEME, QUOTED_STRING, 168 SHREF_TARGET_ MIDDLE, SHREF_TARGET_LAST_CHAR),169 SHREF_TARGET_FIRST, SHREF_TARGET_MIDDLE, SHREF_TARGET_LAST), 169 170 # lhref corresponds to long TracLinks, i.e. [lns:ltgt label?] 170 171 r"(?P<lhref>\[(?:(?P<lns>%s):(?P<ltgt>%s|[^\]\s]*)|(?P<rel>%s))" 171 172 r"(?:\s+(?P<label>%s|[^\]]+))?\])" \
For the rational about the SHREF_TARGET_LAST
, see related #1153.
comment:5 by , 19 years ago
comment:6 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in r2401.
I'll reuse and update the attachment:escape_shref.2.patch for fixing #2251…
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:
Change:[10]
would be interpreted as changeset 10 in the project namedChange
.Test:[[BR]]
could be a valid InterWiki link.test:'''...'''
is interpreted as a link totest:''
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: