allura
Revisão | b8ff1dce5a5df630e773db1f7c89251bdbe389ab (tree) |
---|---|
Hora | 2012-05-10 04:12:59 |
Autor | Rick Copeland <rick@arbo...> |
Commiter | Rick Copeland |
[#3960] Remove /nf/redirect conversions
Signed-off-by: Rick Copeland <rick@arborian.com>
@@ -20,25 +20,3 @@ class NewForgeController(object): | ||
20 | 20 | h.set_context(project, app, neighborhood=neighborhood) |
21 | 21 | html = g.markdown_wiki.convert(markdown) |
22 | 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 | - |
@@ -228,7 +228,6 @@ class RelativeLinkRewriter(markdown.postprocessors.Postprocessor): | ||
228 | 228 | if 'sf.net' in val or 'sourceforge.net' in val: |
229 | 229 | return |
230 | 230 | else: |
231 | - tag[attr] = '/nf/redirect/?path=%s' % h.urlquote(val) | |
232 | 231 | tag['rel']='nofollow' |
233 | 232 | return |
234 | 233 | if val.startswith('/'): return |
@@ -92,15 +92,6 @@ class TestRootController(TestController): | ||
92 | 92 | r = self.app.get('/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True) |
93 | 93 | assert '<p><em>aaa</em>bb<a href="/p/test/wiki/Home/">[wiki:Home]</a></p>' in r, r |
94 | 94 | |
95 | - def test_redirect_external(self): | |
96 | - r = self.app.get('/nf/redirect/?path=%s' % quote('http://en.wikipedia.org/wiki/Aho–Corasick_string_matching_algorithm')) | |
97 | - assert r.status_int == 302 | |
98 | - assert r.location == 'http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm' | |
99 | - | |
100 | - r = self.app.get('/nf/redirect/?path=%s' % quote('http://google.com')) | |
101 | - assert r.status_int == 302 | |
102 | - assert r.location == 'http://google.com' | |
103 | - | |
104 | 95 | def test_slash_redirect(self): |
105 | 96 | r = self.app.get('/p',status=301) |
106 | 97 | r = self.app.get('/p/',status=200) |
@@ -123,9 +123,9 @@ def test_markdown(): | ||
123 | 123 | assert '<a href=' not in g.markdown.convert('# Foo!\n[Rooted]') |
124 | 124 | assert '<a href=' in g.markdown.convert('This is http://sf.net') |
125 | 125 | tgt = 'http://everything2.com/?node=nate+oostendorp' |
126 | - url = '/nf/redirect/?path=%s' % quote(tgt) | |
127 | 126 | s = g.markdown.convert('This is %s' % tgt) |
128 | - assert s == '<div class="markdown_content"><p>This is <a href="%s" rel="nofollow">%s</a></p></div>' % (url, tgt), s | |
127 | + assert_equal( | |
128 | + s, '<div class="markdown_content"><p>This is <a href="%s" rel="nofollow">%s</a></p></div>' % (tgt, tgt)) | |
129 | 129 | assert '<a href=' in g.markdown.convert('This is http://sf.net') |
130 | 130 | # assert '<a href=' in g.markdown_wiki.convert('This is a WikiPage') |
131 | 131 | # assert '<a href=' not in g.markdown_wiki.convert('This is a WIKIPAGE') |