Created
July 4, 2012 12:50
-
-
Save dinge/3047170 to your computer and use it in GitHub Desktop.
DocUtils::Sanitizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DocUtils::Sanitizer | |
@sanitizer = HTML::WhiteListSanitizer.new | |
AllowedTags = { | |
:none => [], | |
:default => %w(u img a i b div br ul li), | |
:only_images => %w(img) | |
} | |
AllowedAttributes = %w(id src href onclick class) | |
def self.cleanup(value, allowed_tags_set = :default) | |
value = @sanitizer.sanitize(value, :tags => AllowedTags[allowed_tags_set], :attributes => AllowedAttributes).to_s | |
value.gsub(/\<br\>$/, '').strip | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment