Guest User

Untitled

a guest
Apr 25th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. A small test to know if Rails 3 will double-escape already escaped strings, say, you've got your typical h(str), will str be escaped once by default and then escaped once again by h()? It does not look like this will happen (tried with rails 2.3.5 and the rails_xss plugin)
  2.  
  3. ### .erb file
  4.  
  5. <% str = "A string that needs <strong>escaping</strong>" %>
  6. <p>
  7. Not escaped: <%= str %>
  8. </p>
  9. <p>
  10. Escaped with h: <%= h str %>
  11. </p>
  12.  
  13. ### Output with Rails 2.3.5
  14. <p>
  15. Not escaped: A string that needs <strong>escaping</strong>
  16. </p>
  17. <p>
  18. Escaped with h: A string that needs <strong>escaping</strong>
  19. </p>
  20.  
  21. ### Output with Rails 2.3.5 with rails_xss and erubis
  22. <p>
  23. Not escaped: A string that needs <strong>escaping</strong>
  24. </p>
  25. <p>
  26. Escaped with h: A string that needs <strong>escaping</strong>
  27. </p>
Add Comment
Please, Sign In to add comment