summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-10-15 18:31:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-10-15 18:31:34 +0000
commitbae4b1985d921d50799da8108657d4432a7f34f7 (patch)
treed9c225d021142a46cf4c77f6eda06e635c571402
parentbf4e5da59bed39e24c76f73c7aec664cf8e9e726 (diff)
downloadredmine-bae4b1985d921d50799da8108657d4432a7f34f7.tar.gz
redmine-bae4b1985d921d50799da8108657d4432a7f34f7.zip
Fixed unsafe call to #casecmp (#20369, #21000).
git-svn-id: http://svn.redmine.org/redmine/trunk@14676 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--test/unit/helpers/application_helper_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4bf9e15c8..60aad08a2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -609,7 +609,7 @@ module ApplicationHelper
parsed << text
if tag
if closing
- if tags.last.casecmp(tag) == 0
+ if tags.last && tags.last.casecmp(tag) == 0
tags.pop
end
else
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 27c711dda..883e9d33e 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -994,6 +994,12 @@ EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
end
+ def test_unbalanced_closing_pre_tag_should_not_error
+ assert_nothing_raised do
+ textilizable("unbalanced</pre>")
+ end
+ end
+
def test_syntax_highlight
raw = <<-RAW
<pre><code class="ruby">