Edgewall Software

Opened 7 years ago

Last modified 2 years ago

#12238 new defect

InterWiki prefix with http works with more symbols then links defined without http

Reported by: martin.stolle@… Owned by:
Priority: low Milestone: next-stable-1.4.x
Component: rendering Version: 1.0.7
Severity: normal Keywords: InterMapTxt, prefix, InterWiki
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


The following definition in the wiki:InterMapTxt will not work with all symbols:

kwquery      /query?group=status&keywords=~  # Custom query for tickets matching keyword $1

in comparison to any prefix using http, e.g.

PEP     http://www.python.org/peps/pep-$1.html    # Python Enhancement Proposal




Not working using an extra :




Attachments (0)

Change History (8)

comment:1 by Ryan J Ollos, 7 years ago

Milestone: next-stable-1.0.x

comment:2 by martin.stolle@…, 6 years ago

Resolution: invalid
Status: newclosed

Open trac.ini, goto section wiki, add foo to safe_schemes, save and restart server.


comment:3 by Jun Omae, 6 years ago

Resolution: invalid
Status: closedreopened

No, no. This is not a safe_schemes issue.

comment:4 by martin.stolle@…, 6 years ago

It clearly fixes the issue and save_schemes is a list of URI schemes considered "safe", that will be rendered as external links.

foo:bar is not safe because it needs to be defined as such.

If is not in safe_schemes issue please define what it is.

comment:5 by Jun Omae, 6 years ago

Workaround is to use %3a instead of :, e.g. kwquery:foo%3abar.

comment:6 by Jun Omae, 6 years ago

After the patch, kwquery:foo:bar would be rendered as /query?group=status&keywords=~foo%3Abar link.

  • trac/wiki/interwiki.py

    diff --git a/trac/wiki/interwiki.py b/trac/wiki/interwiki.py
    index 4132dfcff..768c50f11 100644
    a b from trac.cache import cached  
    2222from trac.config import ConfigSection
    2323from trac.core import *
    2424from trac.util import lazy
     25from trac.util.text import unicode_quote
    2526from trac.util.translation import _, N_
    2627from trac.wiki.api import IWikiChangeListener, IWikiMacroProvider, WikiSystem
    2728from trac.wiki.parser import WikiParser
    class InterWikiMap(Component):  
    6970        """Replace "$1" by the first args, "$2" by the second, etc."""
    7071        def setarg(match):
    7172            num = int(match.group()[1:])
    72             return args[num - 1] if 0 < num <= len(args) else ''
    73         return re.sub(InterWikiMap._argspec_re, setarg, txt)
     73            return unicode_quote(args[num - 1]) if 0 < num <= len(args) else ''
     74        return InterWikiMap._argspec_re.sub(setarg, txt)
    7576    def _expand_or_append(self, txt, args):
    7677        """Like expand, but also append first arg if there's no "$"."""
    7778        if not args:
    7879            return txt
    7980        expanded = self._expand(txt, args)
    80         return txt + args[0] if expanded == txt else expanded
     81        return txt + unicode_quote(args[0]) if expanded == txt else expanded
    8283    def url(self, ns, target):
    8384        """Return `(url, title)` for the given InterWiki `ns`.

comment:7 by Ryan J Ollos, 6 years ago

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:8 by Ryan J Ollos, 2 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x
Status: reopenednew

Modify Ticket

Change Properties
Set your email in Preferences
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.