Skip to content

Commit

Permalink
Remove some dead code that's no longer needed since the switch to Nok…
Browse files Browse the repository at this point in the history
…ogiri
  • Loading branch information
rgrove committed Sep 18, 2009
1 parent c309b0a commit 95278d9
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions lib/sanitize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@

class Sanitize

# Characters that should be replaced with entities in text nodes.
ENTITY_MAP = {
'<' => '&lt;',
'>' => '&gt;',
'"' => '&quot;',
"'" => '&#39;'
}

# Matches an unencoded ampersand that is not part of a valid character entity
# reference.
REGEX_AMPERSAND = /&(?!(?:[a-z]+[0-9]{0,2}|#[0-9]+|#x[0-9a-f]+);)/i

# Matches an attribute value that could be treated by a browser as a URL
# with a protocol prefix, such as "http:" or "javascript:". Any string of zero
# or more characters followed by a colon is considered a match, even if the
Expand Down Expand Up @@ -156,18 +144,6 @@ def clean!(html, config = {})
sanitize = Sanitize.new(config)
sanitize.clean!(html)
end

# Encodes special HTML characters (<, >, ", ', and &) in _html_ as entity
# references and returns the encoded string.
def encode_html(html)
str = html.dup

# Encode special chars.
ENTITY_MAP.each {|char, entity| str.gsub!(char, entity) }

# Convert unencoded ampersands to entity references.
str.gsub(REGEX_AMPERSAND, '&amp;')
end
end

end

0 comments on commit 95278d9

Please sign in to comment.