remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

Using encodeURI breaks some URLs #191

Open codeclown opened 5 years ago

codeclown commented 5 years ago

Background:

Since PR https://github.com/remy/inliner/pull/103 URLs are passed through encodeURI in get.js:

https://github.com/remy/inliner/blob/df3619f89b5b4b76bd1b1bca675a58b38bf7a5b7/lib/get.js#L74

Problem:

This can result in 404s for otherwise working URLs. Example:

<img src="http://example.com/img/ExampleImage%20Space.png" />

Passing it through encodeURI turns the encoded space character %20 into %2520:

encodeURI('http://example.com/img/ExampleImage%20Space.png')
"http://example.com/img/ExampleImage%2520Space.png"

Which breaks the URL, and now we get a 404 for the image when trying to inline it.

codeclown commented 5 years ago

PR made: https://github.com/remy/inliner/pull/192


Anyone bumping into this issue could use my branch for the time being:

yarn add https://github.com/codeclown/inliner.git#encoded-space