Fix Busted Functional Tests

Fix the functional tests busted by Revision 212.
Sync with latest HTML5lib.
This commit is contained in:
Jacques Distler 2008-01-21 11:59:55 -06:00
parent 51474e06c8
commit 5db9ddaf47
12 changed files with 67 additions and 30 deletions

View file

@ -281,7 +281,11 @@ module HTML5
@tell += 1 if @buffer[@tell] == "\n"
c = "\n"
when "\x80" .. "\x9F"
c = ''.force_encoding('UTF-8') << ENTITIES_WINDOWS1252[c.ord-0x80]
c = ENTITIES_WINDOWS1252[c.ord-0x80].chr('utf-8')
when "\xA0" .. "\xFF"
if c.encoding == Encoding::ASCII_8BIT
c = c.encode('utf-8','iso-8859-1')
end
end
if c == "\x0D"
@ -299,8 +303,7 @@ module HTML5
@col += 1
end
# binary utf-8
c.ord > 126 ? [c.ord].pack('U') : c
c
when 0x01..0x7F
if c == 0x0D

View file

@ -7,9 +7,9 @@ module Sniffer
while pos < s.length
case s[pos]
when 0x09, 0x20, 0x0A, 0x0D # tab, space, LF, CR
when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR
pos += 1
when 0x3C # "<"
when ?< # 0x3C
pos += 1
if s[pos..pos+2] == "!--" # [0x21, 0x2D, 0x2D]
pos += 3
@ -17,13 +17,13 @@ module Sniffer
pos += 1
end
pos += 3
elsif s[pos] == 0x21 # "!"
elsif s[pos] == ?! # 0x21
pos += 1
until s[pos] == 0x3E or pos >= s.length # ">"
until s[pos] == ?> or pos >= s.length # 0x3E
pos += 1
end
pos += 1
elsif s[pos] == 0x3F # "?"
elsif s[pos] == ?? # 0x3F
until s[pos..pos+1] == "?>" or pos >= s.length # [0x3F, 0x3E]
pos += 1
end
@ -42,4 +42,4 @@ module Sniffer
"text/html"
end
end
end
end

View file

@ -118,7 +118,11 @@ module HTML5
end
if 0 < charAsInt and charAsInt <= 1114111 and not (55296 <= charAsInt and charAsInt <= 57343)
char = [charAsInt].pack('U')
if String.method_defined? :force_encoding
char = charAsInt.chr('utf-8')
else
char = [charAsInt].pack('U')
end
else
char = [0xFFFD].pack('U')
@token_queue << {:type => :ParseError, :data => "cant-convert-numeric-entity", :datavars => {"charAsInt" => charAsInt}}