This project is archived and is in readonly mode.
Problem with RailsSanitize.white_list_sanitizer.sanitize
Reported by sauce | July 23rd, 2008 @ 03:14 PM | in 2.x
Problem with RailsSanitize.white_list_sanitizer.sanitize.
Example :
RailsSanitize.white_list_sanitizer.sanitize("<a href=\"http://www.domain.com?var1=1&var2=2\">my link</a>") is OK and gives "<a href=\"http://www.domain.com?var1=1&var2=2\">my link</a>"
RailsSanitize.white_list_sanitizer.sanitize("<a href=\"http://www.domain.com?var1=1&var2=2\">my link</a>") is BAD and gives "<a href=\"http://www.domain.com?var1=1&amp;var2=2\">my link</a>"
As I sanitize each time I save my model, rails sanitize each time "&" so string is growing every time. (&amp;amp;amp;...)
Sorry for my english I am french !
Comments and changes to this ticket
-
antonmos August 27th, 2008 @ 07:50 PM
- Tag set to 2.0-stable, 2.1, patch, sanitize
This change set fixes this issue
-
Tietew September 2nd, 2008 @ 06:11 AM
It seems not to be fixed. CGI.unescape does not know much named entities and character references over U+FFFF.
gives
U+20000 is valid character.
In category "CJK Unified Ideographs Extension B"
GOOD result is: or or
-
Tietew September 2nd, 2008 @ 06:15 AM
Oops, tags are stripped...
It seems not to be fixed. CGI.unescape does not know much named entities and character references over U+FFFF.
<img alt="𠀀 is a «kanji»" ...> gives <img alt="&#131072; is a &laquo;kanji&raquo;" ...>
# U+20000 is valid character. # In category "CJK Unified Ideographs Extension B"
GOOD result is: <img alt="𠀀 is a «kanji»" ...> or <img alt="𠀀 is a «kanji»" ...> or <img alt="? is a «kanji»" ...>
-
Ryan McGeary October 17th, 2008 @ 03:41 AM
+1 on antonmos's changes. Here's a formatted patch that incorporates the changes to comply with the Rails contribution guidelines.
-
Christopher Murphy October 17th, 2008 @ 03:55 AM
- This bug has burned me in my app.
Patch works, tests passed.
-
theflow November 6th, 2008 @ 11:17 AM
+1
Patch works great for me. The problem Tietew mentions is a general problem with sanitize and not caused by the proposed patch.
Any chance to get this into 2.2?
-
Repository November 6th, 2008 @ 12:09 PM
- State changed from new to committed
(from [a358d87e16fa876de29286b69474ab6aaee4a80b]) Fixed the sanitize helper to avoid double escaping already properly escaped entities [#683 state:committed] http://github.com/rails/rails/co...
-
Repository November 6th, 2008 @ 12:09 PM
(from [6406a87eedb74a41f19f5ad21ea1b8f97dd45755]) Fixed the sanitize helper to avoid double escaping already properly escaped entities [#683 state:committed] http://github.com/rails/rails/co...
-
iGEL November 14th, 2008 @ 03:15 PM
Sorry, I havn't tried it yet, but it sounds like a bad idea. Maybe as an option, disabled by default.
But what, if the user wants to write & or ä as a comment? As far as I understand, Rails will now ignore these entities and it will be displayed as & or ä.
-
iGEL November 14th, 2008 @ 03:20 PM
If you want a demonstration of the problem, look above. Of course I wanted to write & a m p ; and & a u m l; without spaces (I try double escaping: & ä). What the user enters should be displayed, he shouldn't care about entities and everything...
-
Ryan McGeary November 14th, 2008 @ 03:32 PM
iGEL, I disagree. The purpose of the sanitize method is to sanitize HTML input. The ampersand entities are valid HTML. When displayed, they should display the entities they represent, not the literal codes.
In other words, you should expect [& a m p ;] to be displayed as an ampersand. Just like an html tag shouldn't be escaped to it's lt and gt entities, entities themselves should not be escaped either.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 374 Sanitize treats & entity in URI incorrectly I think #683 is a dupe of this, and it has more informati...
- 714 Problem with attribute escaping (sanitized.rb) +patch this is duplicate of #683 (which proposes the same soluti...
- 683 Problem with RailsSanitize.white_list_sanitizer.sanitize (from [a358d87e16fa876de29286b69474ab6aaee4a80b]) Fixed t...
- 683 Problem with RailsSanitize.white_list_sanitizer.sanitize (from [6406a87eedb74a41f19f5ad21ea1b8f97dd45755]) Fixed t...