|
a/Allura/allura/controllers/static.py |
|
b/Allura/allura/controllers/static.py |
|
... |
|
... |
18 |
if neighborhood is None or project is None:
|
18 |
if neighborhood is None or project is None:
|
19 |
raise exc.HTTPBadRequest()
|
19 |
raise exc.HTTPBadRequest()
|
20 |
h.set_context(project, app, neighborhood=neighborhood)
|
20 |
h.set_context(project, app, neighborhood=neighborhood)
|
21 |
html = g.markdown_wiki.convert(markdown)
|
21 |
html = g.markdown_wiki.convert(markdown)
|
22 |
return html
|
22 |
return html
|
23 |
|
|
|
24 |
@expose()
|
|
|
25 |
@with_trailing_slash
|
|
|
26 |
def redirect(self, path, **kw):
|
|
|
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)
|
|
|
43 |
redirect(path)
|
|
|
44 |
|
|
|