Skip to content

Commit 6f92468

Browse files
committed
Ruby 1.9 += sniffer
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401091
1 parent 4a1710e commit 6f92468

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/html5/sniffer.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ def html_or_feed str
77

88
while pos < s.length
99
case s[pos]
10-
when 0x09, 0x20, 0x0A, 0x0D # tab, space, LF, CR
10+
when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR
1111
pos += 1
12-
when 0x3C # "<"
12+
when ?< # 0x3C
1313
pos += 1
1414
if s[pos..pos+2] == "!--" # [0x21, 0x2D, 0x2D]
1515
pos += 3
1616
until s[pos..pos+2] == "-->" or pos >= s.length
1717
pos += 1
1818
end
1919
pos += 3
20-
elsif s[pos] == 0x21 # "!"
20+
elsif s[pos] == ?! # 0x21
2121
pos += 1
22-
until s[pos] == 0x3E or pos >= s.length # ">"
22+
until s[pos] == ?> or pos >= s.length # 0x3E
2323
pos += 1
2424
end
2525
pos += 1
26-
elsif s[pos] == 0x3F # "?"
26+
elsif s[pos] == ?? # 0x3F
2727
until s[pos..pos+1] == "?>" or pos >= s.length # [0x3F, 0x3E]
2828
pos += 1
2929
end
@@ -42,4 +42,4 @@ def html_or_feed str
4242
"text/html"
4343
end
4444
end
45-
end
45+
end

test19.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
require 'test/test_serializer'
2626

27-
# undebugged
28-
# require 'test/test_sniffer'
27+
require 'test/test_sniffer'
2928

3029
require 'test/test_stream'
3130

0 commit comments

Comments
 (0)