Mercurial > p > roundup > code
comparison test/test_templating.py @ 6103:af16c135fb98
url's with javascript scheme should not be links in reST
A javascript url in a reStructuredText document should not be
displayed as a link. So:
javascript:nastyJavascriptCode
should be displayed as text and not a link.
We do this by stripping the scheme from the schemes array in
docutils.utils.urischemes. We set a property on the
StringHTMLProperty to hold the list of schemes we want to disable so
the user can choose to change it if they want.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 25 Feb 2020 22:48:17 -0500 |
| parents | 55c56ceacb8e |
| children | a1fd9551d416 |
comparison
equal
deleted
inserted
replaced
| 6102:0a82437a2930 | 6103:af16c135fb98 |
|---|---|
| 279 | 279 |
| 280 </pre> | 280 </pre> |
| 281 </div> | 281 </div> |
| 282 </div> | 282 </div> |
| 283 ''' | 283 ''' |
| 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><badtag>\njavascript:badcode</p>\n</div>\n' | |
| 287 | |
| 284 self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n</div>\n')) | 288 self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n</div>\n')) |
| 285 self.assertEqual(q.rst(), u2s(q_result)) | 289 self.assertEqual(q.rst(), u2s(q_result)) |
| 286 self.assertEqual(r.rst(), u2s(r_result)) | 290 self.assertEqual(r.rst(), u2s(r_result)) |
| 291 self.assertEqual(s.rst(), u2s(s_result)) | |
| 287 | 292 |
| 288 @skip_stext | 293 @skip_stext |
| 289 def test_string_stext(self): | 294 def test_string_stext(self): |
| 290 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df')) | 295 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df')) |
| 291 self.assertEqual(p.stext(), u2s(u'<p>A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n')) | 296 self.assertEqual(p.stext(), u2s(u'<p>A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n')) |
