You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Shazron <sh...@gmail.com> on 2012/07/17 22:32:33 UTC

[Android, iOS] UTF-8 encoding URL for FileTransfer

I made a mistake. I didn't realize that Android's FileTransfer does
not do any UTF-8 encoding of the URL and relies on the user encoding
it themselves (default behaviour of java.net.URL
http://docs.oracle.com/javase/6/docs/api/java/net/URL.html).

Thus, I'm reverting this change: https://issues.apache.org/jira/browse/CB-907
(the test case with the Chinese characters there should fail on
Android also, I think)

I tried to see what Android UTF-8 encodes Chinese characters to, but:
    new java.net.URL("http://dummy.org/中文名.txt").toString()
... just returns the same string.

I was thinking that maybe we could do encodeURI (in JavaScript) on the
URL passed to FileTransfer, but then that will just add the
restriction that the URL _cannot_ be encoded already (since we don't
want to double encode).

I think the best thing to do is just simply add in the docs that the
dev *must* encode the URL first using encodeURI.

issues:
    https://issues.apache.org/jira/browse/CB-907
    https://issues.apache.org/jira/browse/CB-1083