diff options
-rw-r--r-- | lib/redcloth3.rb | 2 | ||||
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index d720af9d8..7c9df0727 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -1078,7 +1078,7 @@ class RedCloth3 < String line = "<redpre##{ @pre_list.length }>" first.match(/<#{ OFFTAGS }([^>]*)>/) tag = $1 - $2.to_s.match(/(class\=\S+)/i) + $2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i) tag << " #{$1}" if $1 @pre_list << "<#{ tag }>#{ aftertag }" end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 02b15fbf5..6327442c6 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -275,6 +275,9 @@ RAW "<!-- opening comment" => "<p><!-- opening comment</p>", # remove attributes except class "<pre class='foo'>some text</pre>" => "<pre class='foo'>some text</pre>", + '<pre class="foo">some text</pre>' => '<pre class="foo">some text</pre>', + "<pre class='foo bar'>some text</pre>" => "<pre class='foo bar'>some text</pre>", + '<pre class="foo bar">some text</pre>' => '<pre class="foo bar">some text</pre>', "<pre onmouseover='alert(1)'>some text</pre>" => "<pre>some text</pre>", } to_test.each { |text, result| assert_equal result, textilizable(text) } |