public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed the sanitize helper to avoid double escaping already properly escaped 
entities [#683 state:committed]
dhh (author)
Thu Nov 06 04:02:32 -0800 2008
commit  a358d87e16fa876de29286b69474ab6aaee4a80b
tree    6d5a68b1948a2727fb515c794f1e4854c8eedb3e
parent  077773257b682b7929e77ced3bbf46acf56a10c9
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *2.2.1 [RC2 or 2.2 final]*
0
 
0
+* Fixed the sanitize helper to avoid double escaping already properly escaped entities #683 [antonmos/Ryan McGeary]
0
+
0
 * Fixed that FormTagHelper generated illegal html if name contained square brackets #1238 [Vladimir Dobriakov]
0
 
0
 * Fix regression bug that made date_select and datetime_select raise a Null Pointer Exception when a nil date/datetime was passed and only month and year were displayed #1289 [Bernardo Padua/Tor Erik]
...
160
161
162
163
 
164
165
166
...
160
161
162
 
163
164
165
166
0
@@ -160,7 +160,7 @@ module HTML
0
         if !options[:attributes].include?(attr_name) || contains_bad_protocols?(attr_name, value)
0
           node.attributes.delete(attr_name)
0
         else
0
-          node.attributes[attr_name] = attr_name == 'style' ? sanitize_css(value) : CGI::escapeHTML(value)
0
+          node.attributes[attr_name] = attr_name == 'style' ? sanitize_css(value) : CGI::escapeHTML(CGI::unescapeHTML(value))
0
         end
0
       end
0
     end
...
253
254
255
 
 
 
 
256
257
258
...
253
254
255
256
257
258
259
260
261
262
0
@@ -253,6 +253,10 @@ class SanitizerTest < Test::Unit::TestCase
0
     assert_sanitized "<![CDATA[<span>neverending...", "&lt;![CDATA[&lt;span>neverending...]]>"
0
   end
0
 
0
+  def test_should_not_mangle_urls_with_ampersand
0
+     assert_sanitized %{<a href=\"http://www.domain.com?var1=1&amp;var2=2\">my link</a>}
0
+  end
0
+
0
 protected
0
   def assert_sanitized(input, expected = nil)
0
     @sanitizer ||= HTML::WhiteListSanitizer.new
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 *2.2.1 [RC2 or 2.2 final]*
0
 
0
-* Stop logging SHOW FIELDS and SET SQL_AUTO_IS_NULL=0 as they only clutter up the log and offer no value [DHH]
0
+* Stop logging SHOW FIELDS and SET SQL_AUTO_IS_NULL=0 for the MysqlAdapter as they only clutter up the log and offer no value [DHH]
0
 
0
 * Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster]
0
 

Comments