From f5bb55cc14cc17bc4665347fe6c2e11145101624 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 7 Oct 2012 02:59:02 +0200 Subject: [PATCH] Fix HTML scanner: Don't crash if HTML in a diff contains a JavaScript tag. --- Changes.textile | 1 + lib/coderay/scanners/html.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changes.textile b/Changes.textile index d70c3037..3326a711 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 733dd6fa..49c346db 100644 --- a/lib/coderay/scanners/html.rb +++ b/lib/coderay/scanners/html.rb @@ -69,6 +69,7 @@ def reset def setup @state = :initial @plain_string_content = nil + @in_tag = nil end def scan_java_script encoder, code @@ -83,7 +84,8 @@ def scan_java_script encoder, code 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 @@ def scan_tokens encoder, options 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