This project is archived and is in readonly mode.
h method is not aliased properly
-
Aamer
(Attaching patch)
-
Pratik
- State changed from new to incomplete
- Title changed from [PATCH] h method is not aliased properly to h method is not aliased properly
Could you please add tests for cases that are affected by this behavior ?
Thanks.
-
Aamer
The thing is that I cannot really write a test for it unless I redefine ERB::Util::HTML_ESCAPE, because there is no loss in functionality. The only time the two methods would behave differently is if the value of this constant was changed to something else
... And I don't think it's conventional to redefine Rails constants for the purposes of testing (correct me if I'm wrong).
Even though there is no change in functionality, this is still a design flaw as far as I'm concerned. Since html_escape is redefined by ActionView, then h should also be redefined since they are supposed to be the same method. This is what my patch does by calling alias_method.
Alternatively, the Rails team could simply remove the fist few lines of action_view/template_handlers/erb.rb so that the html_escape method is not redefined by Rails. The default method provided by ERB does the exact same thing (although with less "pretty" code) ... but what is the point of redefining a method if you're not changing any functionality?
-
Jeremy Kemper
but what is the point of redefining a method if you're not changing any functionality?
to improve performance
-
Aamer
Fair enough. In that case, I can't really write a performance-based test, so any other suggestions would be welcome.
-
Prem Sichanugrist (sikachu)
- Tag set to actionpack, patch
- State changed from incomplete to wontfix
-
Wolfram Arnold
Something got broken here recently (with 2.3.8). The h method appears to no longer escape, but calling html_escape does. This started showing up in 2.3.8, but was not an issue in 2.3.5
-
Santiago Pastorino
Wolfram, can you provide a test case or show the code you are trying please?
