brianmario / escape_utils

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

Support escaping XML, filtering its invalid characters #19

Closed dylanahsmith closed 13 years ago

dylanahsmith commented 13 years ago

Fixes issue #18.

Upstream pull request (https://github.com/tanoku/houdini/pull/1) has gotten no feedback for weeks, but the code is well tested now and production ready.

brianmario commented 13 years ago

I'll see if I can nudge @tanoku to take a look, he's been travelling a bit recently - probably still catching up on sleep :P

I'll try and take a look and hopefully merge this tomorrow, thanks a ton!

vmg commented 13 years ago

:metal: :metal: :metal: :metal: :metal: :metal: :metal: :metal:

Beard I merged this for you and backported all the upstream changes from Houdini. Tests are still passing... Did I break something? :)

brianmario commented 13 years ago

@dylanahsmith - any chance we could get XML unescaping too? ;)

dylanahsmith commented 13 years ago

Is there any reason why html unescaping couldn't be used for xml?

brianmario commented 13 years ago

Not sure, I assume the differences between xml and html escaping would come into play?

dylanahsmith commented 13 years ago

The html unescaper should work with all valid xml, since it recognizes the ' entity. I can't think of any problems with this looser parsing.

If you want it to be stricter, then you will need to have an return value on houdini_unescape_xml that indicates that there was an error, then modify a copy of the html escaping code that recognizes only the valid xml entities and returns an error if anything is invalid.