brianmario / escape_utils

Faster string escaping routines for your ruby apps
MIT License
513 stars 52 forks source link

EscapeUtils.escape_html_as_html_safe #30

Closed tmm1 closed 11 years ago

tmm1 commented 11 years ago

Returns a custom subclass of String and optionally sets @html_safe=true in the new instance.

brianmario commented 11 years ago

I kinda like the class ivar thing we talked about earlier where we can do the type check once up front. I'd feel a lot safer using the klass value then.

tmm1 commented 11 years ago

Yea, maybe something like

EscapeUtils.html_string_class = ActiveSupport::SafeBuffer

That method can just raise if you try to use a non-class or non-subclass of String.

tmm1 commented 11 years ago

Added a fallback path for rbx. Although, it looks like the build is still failing because of rb_cvar_set. Can't we use a simple ivar instead?

brianmario commented 11 years ago

Yeah I guess we could just set a regular ivar on the class itself?

gsmendoza commented 10 years ago

Hello. I encountered an issue concerning escape_util's CGI monkeypatch and the cocoon gem. The issue involves converting an ActiveSupport::SafeBuffer to a string in order to escape it properly. Please see https://github.com/nathanvda/cocoon/pull/191. Would setting something like EscapeUtils.html_string_class = ActiveSupport::SafeBuffer resolve this issue? Thanks for the help!