Skip to content

Commit

Permalink
Revert "added some tests and src attr to img"
Browse files Browse the repository at this point in the history
This reverts commit e5a23be.
  • Loading branch information
amercader committed Feb 22, 2017
1 parent d61acd0 commit 97bf46e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
9 changes: 2 additions & 7 deletions ckan/lib/helpers.py
Expand Up @@ -25,7 +25,7 @@
from webhelpers.text import truncate
import webhelpers.date as date
from markdown import markdown
from bleach import clean as clean_html, ALLOWED_TAGS, ALLOWED_ATTRIBUTES
from bleach import clean as clean_html, ALLOWED_TAGS
from pylons import url as _pylons_default_url
from pylons.decorators.cache import beaker_cache
from pylons import config
Expand All @@ -51,9 +51,6 @@
'sup', 'sub', 'strike', 'br', 'hr'
]).union(ALLOWED_TAGS)

MARKDOWN_ATTRIBUTES = copy.deepcopy(ALLOWED_ATTRIBUTES)
MARKDOWN_ATTRIBUTES.setdefault('img', []).extend(['src', 'alt', 'title'])


from ckan.common import (
_, ungettext, g, c, request, session, json, OrderedDict
Expand Down Expand Up @@ -1702,9 +1699,7 @@ def render_markdown(data, auto_link=True, allow_html=False):
data = markdown(data.strip(), safe_mode=False)
else:
data = RE_MD_HTML_TAGS.sub('', data.strip())
data = clean_html(
markdown(data), strip=True,
tags=MARKDOWN_TAGS, attributes=MARKDOWN_ATTRIBUTES)
data = clean_html(markdown(data), strip=True, tags=MARKDOWN_TAGS)
# tags can be added by tag:... or tag:"...." and a link will be made
# from it
if auto_link:
Expand Down
39 changes: 0 additions & 39 deletions ckan/tests/lib/test_helpers.py
Expand Up @@ -159,45 +159,6 @@ def test_render_markdown_auto_link_ignoring_trailing_punctuation(self):
output = '<p>My link: <a href="http://example.com/page.html" target="_blank" rel="nofollow">http://example.com/page.html</a>.</p>'
eq_(h.render_markdown(data), output)

def test_render_markdown_with_js(self):
data = u'[text](javascript: alert(1))'
output = u'<p><a>text</a></p>'
eq_(h.render_markdown(data), output)

def test_event_attributes(self):
data = u'<p onclick="some.script"><img onmouseover="some.script" src="image.png" /> and text</p>'
output = u'<p>and text</p>'
eq_(h.render_markdown(data), output)

def test_ampersand_in_links(self):
data = u'[link](/url?a=1&b=2)'
output = u'<p><a href="/url?a=1&amp;b=2">link</a></p>'
eq_(h.render_markdown(data), output)

data = u'http://example.com/page?a=1&b=2'
output = u'<p><a href="http://example.com/page?a=1&amp;b=2" target="_blank" rel="nofollow">http://example.com/page?a=1&amp;b=2</a></p>'
eq_(h.render_markdown(data), output)

def test_tags_h1(self):
data = u'#heading'
output = u'<h1>heading</h1>'
eq_(h.render_markdown(data), output)

def test_tags_h2(self):
data = u'##heading'
output = u'<h2>heading</h2>'
eq_(h.render_markdown(data), output)

def test_tags_h3(self):
data = u'###heading'
output = u'<h3>heading</h3>'
eq_(h.render_markdown(data), output)

def test_tags_img(self):
data = u'![image](/image.png)'
output = u'<p><img alt="image" src="/image.png"></p>'
eq_(h.render_markdown(data), output)


class TestHelpersRemoveLineBreaks(object):

Expand Down

0 comments on commit 97bf46e

Please sign in to comment.