summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-11-02 07:35:51 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-11-02 07:35:51 +0000
commite300188982d135bf752a59219619a3b648dde6ef (patch)
tree200b446cd699b5b029967011b6b984b28bd8832a
parent23fe2be2469129727d48710d7ec40f43bbd92168 (diff)
downloadredmine-e300188982d135bf752a59219619a3b648dde6ef.tar.gz
redmine-e300188982d135bf752a59219619a3b648dde6ef.zip
add unit test of escaping image urls (#9245)
Contributed by Holger Just. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7707 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index f226fca4e..4d9f90518 100644
--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
@@ -197,6 +197,13 @@ EXPECTED
assert_equal '<p>[msg1][msg2]</p>', to_html('[msg1][msg2]')
end
+ def test_textile_should_escape_image_urls
+ # this is onclick="alert('XSS');" in encoded form
+ raw = '!/images/comment.png"onclick=&#x61;&#x6c;&#x65;&#x72;&#x74;&#x28;&#x27;&#x58;&#x53;&#x53;&#x27;&#x29;;&#x22;!'
+ expected = '<p><img src="/images/comment.png&quot;onclick=&amp;#x61;&amp;#x6c;&amp;#x65;&amp;#x72;&amp;#x74;&amp;#x28;&amp;#x27;&amp;#x58;&amp;#x53;&amp;#x53;&amp;#x27;&amp;#x29;;&amp;#x22;" alt="" /></p>'
+ assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
+ end
+
private
def assert_html_output(to_test, expect_paragraph = true)