brianmario / escape_utils

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

Expose `escape_href` from Houdini #61

Open gjtorikian opened 9 years ago

gjtorikian commented 9 years ago

:wave: @brianmario. I need escape_href exposed from Houdini for a project I'm working on.

The main difference between escape_href and escape_url is that escape_href is a bit looser on the characters it allows. From Houdini's comment:

The following characters will not be escaped:

   -_.+!*'(),%#@?=;:/,+&$ alphanum

Note that this character set is the addition of:

 - The characters which are safe to be in an URL
 - The characters which are *not* safe to be in
 an URL because they are RESERVED characters.

We asume (lazily) that any RESERVED char that
appears inside an URL is actually meant to
have its native function (i.e. as an URL
component/separator) and hence needs no escaping.

The test I've added here is basically the same as escape_url's. Note that there is no unescape_href function.