Ticket #2029 (closed defect: fixed)
Opened 6 years ago
Last modified 6 years ago
Wiki Links with no description should not strip the prefix for external links
| Reported by: | cboos | Owned by: | cboos |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.9 |
| Component: | wiki system | Version: | 0.9b1 |
| Severity: | minor | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
The implementation for #867 ([wiki:Sometext] -> Sometext)
had a bad side-effect for external links: ([http://host] -> //host).
I'll propose a patch for fixing this.
PS: Also contained in the patch is the possibility to
add a ] in the link description, by enclosing the
description in '...' or "..." quotes, like
one can already do for the target.
Attachments
Change History
Changed 6 years ago by cboos
- Attachment external_link_fix.patch added
comment:1 Changed 6 years ago by cboos
- Status changed from new to assigned
Forgot to "accept" the ticket I created.
(see #2045)
comment:2 Changed 6 years ago by cmlenz
I don't understand this change completely:
-
formatter.py
289 289 target = fullmatch.group('ltgt') 290 290 if target and target[0] in "'\"": 291 291 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] 293 300 rel = fullmatch.group('rel') 294 301 if rel: 295 302 return self._make_relative_link(rel, label or rel)
Why would target be empty? I.e. in what case would the ns be used as label? When removing the quotes around the label, why the if label check? Shouldn't the label always be set at that point?
For removing the quotes, I think the following code would be better (as in more readable):
if label and label[0] in ("'", '"'): label = label[1:-1]
Finally, I'd also expand the and/or expression:
if target: label = target if label.startswith('//'): label = ns + ':' + label else: ...
(But again, I don't see why target would be empty.)
comment:3 Changed 6 years ago by cboos
There is a least one situation where the target can be empty:
[search: Search Trac] -> Search Trac
This corresponds to #1937, which would be fixed by the above patch.
comment:4 Changed 6 years ago by cmlenz
Okay, so if you integrate the syntax recommendations I made above, please apply the patch. I'm planning to release 0.9b2 today (or maybe tomorrow).
It would probably also be a good idea to add some comments to the blocks that aren't so obvious ;-).
comment:5 Changed 6 years ago by cboos
- Resolution set to fixed
- Status changed from assigned to closed



The initial patch