|
a/Allura/allura/controllers/static.py |
|
b/Allura/allura/controllers/static.py |
|
... |
|
... |
23 |
|
23 |
|
24 |
@expose()
|
24 |
@expose()
|
25 |
@with_trailing_slash
|
25 |
@with_trailing_slash
|
26 |
def redirect(self, path, **kw):
|
26 |
def redirect(self, path, **kw):
|
27 |
"""Redirect to external sites."""
|
27 |
"""Redirect to external sites."""
|
|
|
28 |
|
|
|
29 |
# Make sure the url can be encoded to iso-8859-1 (required for HTTP
|
|
|
30 |
# headers. If it can't, urlquote it first, then redirect. Allows us to
|
|
|
31 |
# redirect to external links in markdown, even if the url contains
|
|
|
32 |
# unquoted unicode chars.
|
|
|
33 |
try:
|
|
|
34 |
path.encode('ISO-8859-1')
|
|
|
35 |
except UnicodeEncodeError:
|
|
|
36 |
i = path.find('://')
|
|
|
37 |
if i > -1:
|
|
|
38 |
scheme = path[:i+3]
|
|
|
39 |
path = path[i+3:]
|
|
|
40 |
else:
|
|
|
41 |
scheme = ''
|
|
|
42 |
path = scheme + h.urlquote(path)
|
28 |
redirect(path)
|
43 |
redirect(path)
|
29 |
|
44 |
|