From 7ab82019ebefd660ecab96d925fa2aab0bd4824f Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 11 Feb 2013 14:54:55 -0500 Subject: [PATCH] Add more url linkify tests (imported from commit 34e22ede44e8089cc551b1b7350fdf85b3a80cf0) --- zephyr/tests.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/zephyr/tests.py b/zephyr/tests.py index 7b89776fb4..06754a00e5 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -1831,7 +1831,12 @@ int x = 3 ('from http://supervisord.org/running.html:', "

from %s:

", 'http://supervisord.org/running.html'), ('http://raven.io', "

%s

", 'http://raven.io'), ('at https://humbughq.com/api. Check it!', "

at %s. Check it!

", 'https://humbughq.com/api'), - ('goo.gl/abc', "

%s

", 'goo.gl/abc'), + ('goo.gl/abc', "

%s

", 'goo.gl/abc'), + ('http://d.pr/i/FMXO', "

%s

", 'http://d.pr/i/FMXO'), + ('http://fmota.eu/blog/test.html', "

%s

", 'http://fmota.eu/blog/test.html'), + ('http://j.mp/14Hwm3X', "

%s

", 'http://j.mp/14Hwm3X'), + ('http://localhost:9991/?show_debug=1', "

%s

", 'http://localhost:9991/?show_debug=1'), + ('anyone before? (http://d.pr/i/FMXO)', "

anyone before? (%s)

", 'http://d.pr/i/FMXO'), # XSS Sanitization ('javascript:alert(\'hi\');.com', "

%s

", None), # None marks xss @@ -1844,6 +1849,8 @@ int x = 3 ('http://example.com/something?with,commas,in,url, but not at end', "

%s, but not at end

", 'http://example.com/something?with,commas,in,url'), + ('http://www.yelp.com/biz/taim-mobile-falafel-and-smoothie-truck-new-york#query', + "

%s

", 'http://www.yelp.com/biz/taim-mobile-falafel-and-smoothie-truck-new-york#query'), (' some text https://www.google.com/baz_(match)?with=foo&bar=baz with extras', "

some text %s with extras

", 'https://www.google.com/baz_(match)?with=foo&bar=baz'), ('hash it http://foo.com/blah_(wikipedia)_blah#cite-1', @@ -1860,6 +1867,17 @@ int x = 3 converted = convert(inline_url) self.assertEqual(match, converted) + def test_linkify_interference(self): + # Check our auto links don't interfere with normal markdown linkification + msg = 'link: xx, x xxxxx xx xxxx xx\n\n[xxxxx #xx](xxxx://xxxxxxxxx:xxxx/xxx/xxxxxx%xxxxxx/xx/):\ +**xxxxxxx**\n\nxxxxxxx xxxxx xxxx xxxxx:\n`xxxxxx`: xxxxxxx\n`xxxxxx`: xxxxx\n`xxxxxx`: xxxxx xxxxx' + converted = convert(msg) + + self.assertEqual(converted, '

link: xx, x xxxxx xx xxxx xx

\n

xxxxx #xx:\ +xxxxxxx

\n

xxxxxxx xxxxx xxxx xxxxx:
\nxxxxxx: xxxxxxx
\nxxxxxx: xxxxx\ +
\nxxxxxx: xxxxx xxxxx

') + class UserPresenceTests(AuthedTestCase): fixtures = ['messages.json']