Edgewall Software
Modify

Opened 14 years ago

Last modified 14 years ago

#9734 new defect

Redirecting to non-HTTP URLs not possible

Reported by: Mitar Owned by:
Priority: normal Milestone: next-major-releases
Component: general Version:
Severity: normal Keywords:
Cc: mmitar@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Redirecting to non-HTTP URLs is not possible because of the check in the code which assumes only http or https based URLs. Of course redirect should work for any valid URL.

I also doubt there is any reason why Trac itself should try to fix non-absolute URLs. This is browser's work to do.

Attachments (0)

Change History (9)

comment:1 by Christian Boos, 14 years ago

What's the use case for redirecting to non-HTTP URLs?

Besides, one of the reasons for Trac using absolute URLs is #697, the other is simply the rfc:2616#section-14.30 itself.

comment:2 by Mitar, 14 years ago

Ehm, redirecting to FTP, mailto:, magnet:, Skype links? For example?

2396#section-3 says that:

in general, absolute URI are written as follows:

      <scheme>:<scheme-specific-part>

So any scheme. ;-)

comment:3 by Christian Boos, 14 years ago

Well, the question about the use case was more to enlighten me about the scenario you had in mind for such redirects.

For example, in Trac after the creation of a ticket, you're redirected to the view for the newly created ticket.

So, after what kind of user interaction would you like to redirect to such FTP, mailto:, etc. URLs? (as opposed to simply having links to such URLs?)

comment:4 by Mitar, 14 years ago

So this function is used in any plugin which redirects somewhere. So the scenario is everywhere where we do not talk directly about the displayed content (like wiki) with links.

For example a plugin which converts all external links to local ones (which are handled by the plugin) and then redirect to them comes to mind. In this way you can follow statistics about external links, check for spam links, etc.

How I come about this problem was when I wanted to use ServerSideRedirectPlugin plugin to redirect to non-HTTP link (in my given scenario to Skype public chat link with skype: schema).

comment:5 by Remy Blank, 14 years ago

The Request.redirect() method is there to make it easy to do the right thing in 99% of the situations. This includes converting relative links to absolute links, as you have noticed.

Note that nothing prevents you from constructing your own redirect. It's just a matter of setting the right headers.

comment:6 by Mitar, 14 years ago

The use of APIs and standard utility functions is that developers do not have to thing about all corner (1%) cases all the time, again and again. For example, developer of ServerSideRedirectPlugin uses the function to redirect. Why would he need to think of such special cases (or even know that redirect does not handle them properly).

But I agree. Those cases are rare. I just say that we can do better. Try to match [valid schema chars]+: and if there is nothing like that at the beginning we assume relative URL and create absolute URL. Why limit just to (99%) HTTP and HTTPS? I doubt there is a lot of relative URLs which start with [valid schema chars]+: (and were not already processed as Trac links).

comment:7 by Remy Blank, 14 years ago

Milestone: next-major-0.1X

I'm not saying we can't do better, and your suggestion (about supporting absolute URLs with other schemes) makes sense. My reply was more about the "should not fix relative URLs" part. PatchWelcome.

Do you happen to know which browsers support redirecting to e.g. ftp:, skype: or mailto: URLs?

comment:8 by Mitar, 14 years ago

Firefox for sure. For some it opens external application (or first dialog box to confirm that).

comment:9 by helend, 14 years ago

I have the same problem. But I fixed this problem through changing these two files. A new prototype "zotero" is added. I don't know why, but it works.

C:\Python26\Lib\site-packages\trac\wiki\api.py Line 218: 'cvs,file,ftp,git,irc,http,https,news,sftp,smb,ssh,svn,svn+ssh,zotero',

C:\Python26\Lib\urlparse.py Line 32-48:

uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap',

'wais', 'file', 'https', 'shttp', 'mms', 'prospero', 'rtsp', 'rtspu', , 'sftp', 'zotero']

uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',

'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', , 'svn', 'svn+ssh', 'sftp','nfs','git', 'git+ssh', 'zotero']

non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',

'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']

uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',

'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', 'mms', , 'sftp', 'zotero']

uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms',

'gopher', 'rtsp', 'rtspu', 'sip', 'sips', ]

uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news',

'nntp', 'wais', 'https', 'shttp', 'snews', 'file', 'prospero', , 'zotero']

Modify Ticket

Change Properties
Set your email in Preferences
Action
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.