43081j / id3

A JavaScript ID3 tags parser for Node & browsers.
MIT License
335 stars 63 forks source link

Use `encodeURIComponent` instead of `escape`. #16

Closed yaymukund closed 9 years ago

yaymukund commented 10 years ago

Fixed #15 for me (Uncaught URIError: URI malformed)

escape is bad practice. See http://stackoverflow.com/a/3608791/1207223

43081j commented 10 years ago

Whoops, really unusual for me to use escape instead, not entirely sure why i did.

Will merge this and fix a few other things today if I get chance.

yaymukund commented 10 years ago

And thank you for maintaining this library! It works great :racehorse:

43081j commented 10 years ago

Ah I was just about to merge this and remembered, here's why we used it:

decodeURIComponent('\xD0\xAD') is capital eth (U+00D0) followed by a soft hyphen (U+00AD). decodeURIComponent(escape('\xD0\xAD')) is reversed capital E (U+042D). decodeURIComponent(encodeURIComponent('\xD0\xAD')) results in the same as without escape.

The correct result is the reversed capital E.

See the issue here.