一个例子:
[Dev]> ActionController::Base.helpers.sanitize('<a href="http://google.com">test</a>')
=> '<a href="http://google.com">test</a>'
[Dev]> ActionController::Base.helpers.sanitize('<a href="Http://google.com">test</a>')
=> '<a>test</a>'
非常令人沮丧!
答案 0 :(得分:2)
这似乎是action_controller / vendor / html-scanner / html / sanitizer.rb中方法contains_bad_protocols?
中的错误。此方法定义为:
def contains_bad_protocols?(attr_name, value)
uri_attributes.include?(attr_name) &&
(value =~ /(^[^\/:]*):|(�*58)|(p)|(%|%)3A/
&& !allowed_protocols.include?(value.split(protocol_separator).first))
end
并且allowed_protocols为:
self.allowed_protocols = Set.new(%w(ed2k ftp http https irc mailto news gopher nntp
telnet webcal xmpp callto feed svn urn aim rsync tag ssh sftp rtsp afs))
因此:
allowed_protocols.include? 'http' => true
allowed_protocols.include? 'Http' => false