diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4bf9e15..60aad08 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 27c711d..883e9d3 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") + end + end + def test_syntax_highlight raw = <<-RAW