You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/02/20 21:03:59 UTC

git commit: Revert "[#5358] allow markdown escapes within autolinked URLs" since it breaks [a](http://a.com)

Updated Branches:
  refs/heads/master f9f80242b -> cb0892c16


Revert "[#5358] allow markdown escapes within autolinked URLs" since it breaks [a](http://a.com)

This reverts commit bdd590a14134471c7e487f3cff1b9d1727d48148.


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cb0892c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cb0892c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cb0892c1

Branch: refs/heads/master
Commit: cb0892c162cf195986ecaab6a21840cf5fcf2ee4
Parents: f9f8024
Author: Dave Brondsema <db...@geek.net>
Authored: Wed Feb 20 19:59:34 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Wed Feb 20 20:03:33 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py |    6 +-----
 Allura/allura/tests/test_globals.py      |   12 ++++--------
 2 files changed, 5 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb0892c1/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 1f50876..c004db0 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -38,8 +38,7 @@ class ForgeExtension(markdown.Extension):
         md.preprocessors['fenced-code'] = FencedCodeProcessor()
         md.preprocessors.add('plain_text_block', PlainTextPreprocessor(md), "_begin")
         md.preprocessors.add('macro_include', ForgeMacroIncludePreprocessor(md), '_end')
-        # this has to be before the 'escape' processor, otherwise weird placeholders are inserted for escaped chars within urls, and then the autolink can't match the whole url
-        md.inlinePatterns.add('autolink_without_brackets', AutolinkPattern(r'(http(?:s?)://[a-zA-Z0-9./\-\\_%?&=+#;~:]+)'), '<escape')
+        md.inlinePatterns['autolink_1'] = AutolinkPattern(r'(http(?:s?)://[a-zA-Z0-9./\-_0%?&=+#;~:]+)')
         # replace the link pattern with our extended version
         md.inlinePatterns['link'] = ForgeLinkPattern(markdown.inlinepatterns.LINK_RE, md, ext=self)
         md.inlinePatterns['short_reference'] = ForgeLinkPattern(markdown.inlinepatterns.SHORT_REF_RE, md, ext=self)
@@ -281,9 +280,6 @@ class AutolinkPattern(markdown.inlinepatterns.LinkPattern):
         old_link = mo.group(2)
         result = markdown.util.etree.Element('a')
         result.text = old_link
-        # since this is run before the builtin 'escape' processor, we have to do our own unescaping
-        for char in markdown.Markdown.ESCAPED_CHARS:
-            old_link = old_link.replace('\\' + char, char)
         result.set('href', old_link)
         return result
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb0892c1/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 9640873..d4c570e 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -260,18 +260,14 @@ def foo(): pass
 
 
 def test_markdown_autolink():
-    assert '<a href=' in g.markdown.convert('This is http://sf.net')
+    #with h.set_context('test', 'wiki', neighborhood='Projects')
+    text = g.markdown.convert('This is http://sf.net')
+    assert '<a href=' in text, text
     tgt = 'http://everything2.com/?node=nate+oostendorp'
     s = g.markdown.convert('This is %s' % tgt)
     assert_equal(
         s, '<div class="markdown_content"><p>This is <a href="%s" rel="nofollow">%s</a></p></div>' % (tgt, tgt))
-
-
-def test_markdown_autolink_with_escape():
-    # \_ is unnecessary but valid markdown escaping and should be considered as a regular underscore
-    # (it occurs during html2text conversion during project migrations)
-    r = g.markdown.convert('a http://www.phpmyadmin.net/home\_page/security/\#target b')
-    assert 'href="http://www.phpmyadmin.net/home_page/security/#target"' in r, r
+    assert '<a href=' in g.markdown.convert('This is http://sf.net')
 
 
 def test_macro_projects():