Skip to content

Commit

Permalink
Ruby 1.9 += sniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
sa3ruby committed Jan 20, 2008
1 parent 7144558 commit b70cc51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ruby/lib/html5/sniffer.rb
Expand Up @@ -7,23 +7,23 @@ def html_or_feed str

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
until s[pos..pos+2] == "-->" or pos >= s.length
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
Expand All @@ -42,4 +42,4 @@ def html_or_feed str
"text/html"
end
end
end
end
3 changes: 1 addition & 2 deletions ruby/test19.rb
Expand Up @@ -24,8 +24,7 @@

require 'test/test_serializer'

# undebugged
# require 'test/test_sniffer'
require 'test/test_sniffer'

require 'test/test_stream'

Expand Down

0 comments on commit b70cc51

Please sign in to comment.