jsc3d
jsc3d copied to clipboard
Cannot load URLs with special characters
What steps will reproduce the problem?
1. Use a SceneUrl URL like "http://example.com/foo%20bar.stl"
What is the expected output? What do you see instead?
- Even though the URL is properly-encoded, it fails to load the file.
- On the network, it shows that it actually tried to open
"http://example.com/foo%2520bar.stl"
What version of the product are you using? On what operating system?
- Latest SVN Checkout
- Google Chrome Canary 40
Please provide any additional information below.
This happens because it calls `encodeURI` on the URL even though it is already
properly encoded. To prevent double-encodings, `encodeURI` should not be called
here but by the implementor that uses the links if he thinks his URLs are not
properly encoded already.
The attached patch removes calls to `encodeURI` and fixes the problem.
Original issue reported on code.google.com by [email protected] on 13 Oct 2014 at 12:17
Attachments:
I just found a discussion on a similar issue on stackoverflow:
http://stackoverflow.com/questions/2295223/how-to-find-out-if-string-has-already
-been-url-encoded?lq=1. It enlightens me that since decodeURI() is harmless,
maybe we can decode an URL and then encode it again like this:
encodeURI( decodeURI(url) );
I think it should produce the expected result whether the given URL has been
encoded or not. Not sure. Still needs more tests.
Original comment by [email protected] on 14 Oct 2014 at 9:53
[deleted comment]
It seems to work as intended. If you think people might enter unencoded URLs,
this would do the trick!
--
Sunny
http://github.com/sunny
Original comment by [email protected] on 14 Oct 2014 at 5:55