Sanitize url refs in SVG attributes

Add some tests.
Sync with latest HTML5lib (includes above sanitization improvements).
This commit is contained in:
Jacques Distler 2007-10-27 17:34:29 -05:00
parent ae82f1be49
commit 5208bbf0af
28 changed files with 1277 additions and 735 deletions

View file

@ -47,7 +47,7 @@ module HTML5
#Encoding to use if no other information can be found
@DEFAULT_ENCODING = 'windows-1252'
#Detect encoding iff no explicit "transport level" encoding is supplied
if @encoding.nil? or not HTML5.is_valid_encoding(@encoding)
@char_encoding = detect_encoding
@ -235,14 +235,16 @@ module HTML5
# Returns (line, col) of the current position in the stream.
def position
line, col = @line, @col
@queue.reverse.each do |c|
if c == "\n"
line -= 1
raise RuntimeError.new("col=#{col}") unless col == 0
col = @line_lengths[line]
else
col -= 1
end
if @queue and @queue.last != :EOF
@queue.reverse.each do |c|
if c == "\n"
line -= 1
raise RuntimeError.new("col=#{col}") unless col == 0
col = @line_lengths[line]
else
col -= 1
end
end
end
return [line + 1, col]
end
@ -434,7 +436,13 @@ module HTML5
end
break unless keep_parsing
end
@encoding = @encoding.strip unless @encoding.nil?
unless @encoding.nil?
@encoding = @encoding.strip
if ["UTF-16", "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", "UTF-32LE"].include?(@encoding.upcase)
@encoding = 'utf-8'
end
end
return @encoding
end