Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML encoding messed up with remotipart #71

Closed
yasirs opened this issue Mar 28, 2013 · 2 comments
Closed

HTML encoding messed up with remotipart #71

yasirs opened this issue Mar 28, 2013 · 2 comments

Comments

@yasirs
Copy link

yasirs commented Mar 28, 2013

Some HTML code is messed up due to quotes and the like if AJAX is delivered through remotipart. For a demo, head over to http://shielded-savannah-6910.herokuapp.com/ and look at the encoding in the AJAX responses. Basically, if I have

<% c = '"' %>
<input type="text" value="<%= h c %>">

or

<%= text_field_tag :name, c %>

Then this HTML does not put the value attribute with a double quote if delivered through remotipart, but does the expected thing without remotipart. Remotipart should not change the default behavior of views.

The partial delivered is at https://github.com/yasirs/encoding-demo/blob/hero/app/views/application/_form_partial.html.erb

@yasirs
Copy link
Author

yasirs commented Apr 1, 2013

The issue seems to be that https://github.com/JangoSteve/remotipart/blob/master/lib/remotipart/render_overrides.rb#L16 uses html_escape_once. However, html_escape_once from Rails can't always escape HTML if it already has escaped entities. (See rails/rails#10032 for a discussion). And we need escaped HTML when securely dealing with arbitrary data (which happens all the time).

This was referenced Apr 1, 2013
JangoSteve pushed a commit that referenced this issue Jul 5, 2013
@JangoSteve
Copy link
Owner

Thank you very much for the detailed report and the sample app. I managed to turn this into a test case in remotipart's test suite. It should be fixed now:

JangoSteve/Rails-jQuery-Demo@6c2af5b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants