2007-01-22 14:43:50 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
|
|
require 'chunks/nowiki'
|
|
|
|
|
|
|
|
class NoWikiTest < Test::Unit::TestCase
|
|
|
|
include ChunkMatch
|
|
|
|
|
|
|
|
def test_simple_nowiki
|
|
|
|
match(NoWiki, 'This sentence contains <nowiki>[[raw text]]</nowiki>. Do not touch!',
|
|
|
|
:plain_text => '[[raw text]]'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-05-21 00:02:10 +02:00
|
|
|
def test_markdown_nowiki
|
|
|
|
match(NoWiki, 'This sentence contains <nowiki>*raw text*</nowiki>. Do not touch!',
|
|
|
|
:plain_text => '*raw text*'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-05-21 09:06:31 +02:00
|
|
|
def test_sanitize_nowiki
|
2008-05-21 00:02:10 +02:00
|
|
|
match(NoWiki, 'This sentence contains <nowiki>[[test]]&<a href="a&b">shebang</a> <script>alert("xss!");</script> *foo*</nowiki>. Do not touch!',
|
2008-05-21 09:06:31 +02:00
|
|
|
:plain_text => "[[test]]&<a href='a&b'>shebang</a> <script>alert(\"xss!\");</script> *foo*"
|
2008-05-21 00:02:10 +02:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-12-01 04:44:52 +01:00
|
|
|
def test_sanitize_nowiki_ill_formed
|
|
|
|
match(NoWiki, "<nowiki><animateColor xlink:href='#foo'/></nowiki>",
|
2008-12-01 17:29:46 +01:00
|
|
|
:plain_text => "<animateColor xlink:href='#foo'></animateColor>"
|
2008-12-01 04:44:52 +01:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-12-07 07:24:25 +01:00
|
|
|
def test_sanitize_nowiki_ill_formed_II
|
|
|
|
match(NoWiki, "<nowiki><animateColor xlink:href='#foo'/>\000</nowiki>",
|
|
|
|
:plain_text => %(<animateColor xlink:href='#foo'></animateColor>\xEF\xBF\xBD)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|