no8fear / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Cannot load URLs with special characters #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 negatif@gmail.com on 13 Oct 2014 at 12:17

Attachments:

GoogleCodeExporter commented 9 years ago
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 Humu2...@gmail.com on 14 Oct 2014 at 9:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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 negatif@gmail.com on 14 Oct 2014 at 5:55