Edgewall Software
Modify

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

external_link_fix.patch (3.0 KB) - added by cboos 6 years ago.
The initial patch

Download all attachments as: .zip

Change History

Changed 6 years ago by cboos

The initial patch

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

     
    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) 

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

Reworked patch applied in r2268.
Additional unit tests added in r2269.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from cboos. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.