summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2012-10-07 02:59:02 +0200
committerKornelius Kalnbach <murphy@rubychan.de>2012-10-07 02:59:02 +0200
commitf5bb55cc14cc17bc4665347fe6c2e11145101624 (patch)
tree47bc838a11c6cca0b81c42ee05c50d5a2ce9f681
parent5f54b367d9161a3c5ac30dcc70bd8de5dc378167 (diff)
downloadcoderay-f5bb55cc14cc17bc4665347fe6c2e11145101624.tar.gz
Fix HTML scanner: Don't crash if HTML in a diff contains a JavaScript tag.
-rw-r--r--Changes.textile1
-rw-r--r--lib/coderay/scanners/html.rb5
2 files changed, 5 insertions, 1 deletions
diff --git a/Changes.textile b/Changes.textile
index d70c303..3326a71 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -7,6 +7,7 @@ p=. _This files lists all changes in the CodeRay library since the 0.9.8 release
h2. Next Version
* add @:string/:char@, remove @:regexp/:function@ color from Terminal encoder [GH #29, thanks to Kyrylo Silin]
+* Fix HTML scanner: Don't crash if HTML in a diff contains a JavaScript tag.
h2. Changes in 1.0.7
diff --git a/lib/coderay/scanners/html.rb b/lib/coderay/scanners/html.rb
index 733dd6f..49c346d 100644
--- a/lib/coderay/scanners/html.rb
+++ b/lib/coderay/scanners/html.rb
@@ -69,6 +69,7 @@ module Scanners
def setup
@state = :initial
@plain_string_content = nil
+ @in_tag = nil
end
def scan_java_script encoder, code
@@ -83,7 +84,8 @@ module Scanners
def scan_tokens encoder, options
state = options[:state] || @state
plain_string_content = @plain_string_content
- in_tag = in_attribute = nil
+ in_tag = @in_tag
+ in_attribute = nil
encoder.begin_group :string if state == :attribute_value_string
@@ -237,6 +239,7 @@ module Scanners
if options[:keep_state]
@state = state
@plain_string_content = plain_string_content
+ @in_tag = in_tag
end
encoder.end_group :string if state == :attribute_value_string