From e84bb5d9cf6a40bafbde0c3bcc3c99adbfd18c09 Mon Sep 17 00:00:00 2001 From: murphy Date: Sat, 17 Apr 2010 00:03:51 +0000 Subject: Fixing bug in Java and JSON scanners (unfinished strings where not closed correctly). --- lib/coderay/scanners/java.rb | 2 +- lib/coderay/scanners/json.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'lib/coderay') diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index 2dfb1b6..e4a7421 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -149,7 +149,7 @@ module Scanners elsif scan(/\\./m) kind = :content elsif scan(/ \\ | $ /x) - tokens << [:close, :delimiter] + tokens << [:close, state] kind = :error state = :initial else diff --git a/lib/coderay/scanners/json.rb b/lib/coderay/scanners/json.rb index 163ec46..ca74ff3 100644 --- a/lib/coderay/scanners/json.rb +++ b/lib/coderay/scanners/json.rb @@ -14,9 +14,6 @@ module Scanners :error, :integer, :operator, :value, ] # :nodoc: - CONSTANTS = %w( true false null ) # :nodoc: - IDENT_KIND = WordList.new(:key).add(CONSTANTS, :value) # :nodoc: - ESCAPE = / [bfnrt\\"\/] /x # :nodoc: UNICODE_ESCAPE = / u[a-fA-F0-9]{4} /x # :nodoc: @@ -26,7 +23,6 @@ module Scanners state = :initial stack = [] - string_delimiter = nil key_expected = false until eos? @@ -50,7 +46,7 @@ module Scanners when '}', ']' then stack.pop # no error recovery, but works for valid JSON end elsif match = scan(/ true | false | null /x) - kind = IDENT_KIND[match] + kind = :value elsif match = scan(/-?(?:0|[1-9]\d*)/) kind = :integer if scan(/\.\d+(?:[eE][-+]?\d+)?|[eE][-+]?\d+/) @@ -79,7 +75,7 @@ module Scanners elsif scan(/\\./m) kind = :content elsif scan(/ \\ | $ /x) - tokens << [:close, :delimiter] + tokens << [:close, state] kind = :error state = :initial else -- cgit v1.2.1