Skip to content

Commit 4751a9b

Browse files
committed
issue2551099 - disable processing of data url's in markdown.
Display as plain text. Added 'data' to templating.py _disable_url_schemes array. User should be able to re-enable it by changing the array from the tracker's interfaces.py. Markdown tests failed before the change to _disable_url_schemes. Also add second separate data test for ReST and plain text processing. data url's look like they are already ignored in these proess streams.
1 parent e8a9726 commit 4751a9b

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Fixed:
4545
- issue2551097 - fix underlying bug in use of fenced codeblocks with
4646
markdown2. Fix for issue2551093 to prevent exception trigger.
4747
(patch: Cedric Krier)
48+
- issue2551099 - disable processing of data url's in markdown. Display
49+
as plain text. (John Rouillard)
4850

4951
Features:
5052
- issue2550522 - Add 'filter' command to command-line

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__docformat__ = 'restructuredtext'
2121

2222
# List of schemes that are not rendered as links in rst and markdown.
23-
_disable_url_schemes = [ 'javascript' ]
23+
_disable_url_schemes = [ 'javascript', 'data' ]
2424

2525
import base64, cgi, re, os.path, mimetypes, csv, string
2626
import calendar

test/test_templating.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,10 @@ def test_string_rst(self):
281281
</div>
282282
</div>
283283
'''
284-
# test case to make sure javascript url's aren't turned into links
285-
s = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'<badtag>\njavascript:badcode'))
286-
s_result = '<div class="document">\n<p>&lt;badtag&gt;\njavascript:badcode</p>\n</div>\n'
284+
# test case to make sure javascript and data url's aren't turned
285+
# into links
286+
s = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'<badtag>\njavascript:badcode data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=='))
287+
s_result = '<div class="document">\n<p>&lt;badtag&gt;\njavascript:badcode data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==</p>\n</div>\n'
287288

288289
self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw&#64;example.com">cmeerw&#64;example.com</a> <em>embedded</em> \u00df</p>\n</div>\n'))
289290
self.assertEqual(q.rst(), u2s(q_result))
@@ -489,6 +490,16 @@ def test_string_markdown_javascript_link(self):
489490
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'[link](javascript:alert(1))'))
490491
self.assertTrue(p.markdown().find('href="javascript:') == -1)
491492

493+
def test_string_markdown_data_link(self):
494+
# make sure we don't get a "data:" link
495+
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'<data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==>'))
496+
print(p.markdown())
497+
self.assertTrue(p.markdown().find('href="data:') == -1)
498+
499+
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'[data link](data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==)'))
500+
print(p.markdown())
501+
self.assertTrue(p.markdown().find('href="data:') == -1)
502+
492503

493504
def test_string_markdown_forced_line_break(self):
494505
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'This is a set of text \n:that should have a break \n:at newlines. Each \n:colon should be the start of an html line'))

0 commit comments

Comments
 (0)