Skip to content

Commit

Permalink
Fix HTML scanner: Don't crash if HTML in a diff contains a JavaScript…
Browse files Browse the repository at this point in the history
… tag.
  • Loading branch information
korny committed Oct 7, 2012
1 parent 5f54b36 commit f5bb55c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.textile
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion lib/coderay/scanners/html.rb
Expand Up @@ -69,6 +69,7 @@ def reset
def setup
@state = :initial
@plain_string_content = nil
@in_tag = nil
end

def scan_java_script encoder, code
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f5bb55c

Please sign in to comment.