mathiasbynens / he

A robust HTML entity encoder/decoder written in JavaScript.
https://mths.be/he
MIT License
3.43k stars 255 forks source link

documentation improvement #49

Closed mirabilos closed 8 years ago

mirabilos commented 8 years ago

make it clear that the 'strict' option removes the input being valid constraint

(without 'strict', the output is only valid if the input is valid; some people require an encoder that takes any input, valid or not, and encodes it into valid output (or throws an exception if it cannot be encoded), i.e. does not silently pass invalid input into invalid output)

mirabilos commented 8 years ago

Test (in Firebug’s Konsole):

> he.encode("foo \x22 bar",{strict:true})
"foo &x22; bar"
> he.encode("foo \x02 bar",{strict:true})
Error: Parse error: forbidden code point
> he.encode("foo \x00 bar",{strict:true})
Error: Parse error: forbidden code point

So, adding the 'strict' option makes the he.encode() function usable as a general encoding library.

codecov-io commented 8 years ago

Current coverage is 96.79% (diff: 100%)

No coverage report found for master at d2c219f.

Powered by Codecov. Last update d2c219f...82ba170

mathiasbynens commented 8 years ago

I’ve decided to phrase it differently, but consider this merged! Thanks.