[ https://issues.apache.org/jira/browse/CB-9891?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Connor Pearson updated CB-9891: ------------------------------- Description: Using the camera plugin to get a picture from the photo library returns an encoded URI. If you then call resolveLocalFileSystemURI the fileEntry object returned contains the decoded path component of the URI. This path property is used in the toInternalURL function which means it's also decoded. Because Android gave us permission to the encoded URI, but not the decoded URI, attempting to access the decoded URI results in a permission error. {code:javascript} document.getElementById("myButton").addEventListener("click", function(){ navigator.camera.getPicture(function(uri){ console.log(uri); //content://com.android.providers.media.documents/document/image%3A27 window.resolveLocalFileSystemURI(uri, function(fileEntry){ console.log(fileEntry.toInternalURL()); //cdvfile://localhost/content/com.android.providers.media.documents/document/image:27 fileEntry.file(function(){alert("success");}, function(){alert("fail");}); },function(error){ // resolved by pulling in PR 119 alert("Fail resolveFileSystemURI code: " + error.code); }); }, null, {sourceType: 0, allowEdit: false}); }); {code} I feel like something must be wrong in one of the plugins, but I'm not sure where. In the android FileSystem.js, replacing the second line of the function with {code:javascript} path = path.replace('//', '/').replace(':', '%3A'); {code} solves this specific issue, but it may cause other problems. What is the correct way of handing URIs throughout the file plugin? was: Using the camera plugin to get a picture from the photo library returns an encoded URI. If you then call resolveLocalFileSystemURI the fileEntry object returned contains the decoded path component of the URI. This path property is used in the toInternalURL function which means it's also decoded. Because Android gave us permission to the encoded URI, but not the decoded URI, attempting to access the decoded URI results in a permission error. {code:javascript} document.getElementById("myButton").addEventListener("click", function(){ navigator.camera.getPicture(function(uri){ console.log(uri); //content://com.android.providers.media.documents/document/image%3A27 window.resolveLocalFileSystemURI(uri, function(fileEntry){ console.log(fileEntry.toInternalURL()); //cdvfile://localhost/content/com.android.providers\ .media.documents/document/image:27 fileEntry.file(function(){alert("success");}, function(){alert("fail");}); },function(error){ // resolved by pulling in PR 119 alert("Fail resolveFileSystemURI code: " + error.code); }); }, null, {sourceType: 0, allowEdit: false}); }); {code} I feel like something must be wrong in one of the plugins, but I'm not sure where. In the android FileSystem.js, replacing the second line of the function with {code:javascript} path = path.replace('//', '/').replace(':', '%3A'); {code} solves this specific issue, but it may cause other problems. What is the correct way of handing URIs throughout the file plugin? > Inconsistent URI encoding causing permission errors on android > -------------------------------------------------------------- > > Key: CB-9891 > URL: https://issues.apache.org/jira/browse/CB-9891 > Project: Apache Cordova > Issue Type: Bug > Components: Plugin Camera, Plugin File > Affects Versions: 2.1.0, 3.0.0 > Environment: Android 5+ > Reporter: Connor Pearson > > Using the camera plugin to get a picture from the photo library returns an > encoded URI. If you then call resolveLocalFileSystemURI the fileEntry object > returned contains the decoded path component of the URI. This path property > is used in the toInternalURL function which means it's also decoded. Because > Android gave us permission to the encoded URI, but not the decoded URI, > attempting to access the decoded URI results in a permission error. > {code:javascript} > document.getElementById("myButton").addEventListener("click", function(){ > navigator.camera.getPicture(function(uri){ > console.log(uri); > //content://com.android.providers.media.documents/document/image%3A27 > window.resolveLocalFileSystemURI(uri, function(fileEntry){ > console.log(fileEntry.toInternalURL()); > //cdvfile://localhost/content/com.android.providers.media.documents/document/image:27 > > fileEntry.file(function(){alert("success");}, > function(){alert("fail");}); > },function(error){ > // resolved by pulling in PR 119 > alert("Fail resolveFileSystemURI code: " + error.code); > }); > }, null, {sourceType: 0, allowEdit: false}); > }); > {code} > I feel like something must be wrong in one of the plugins, but I'm not sure > where. In the android FileSystem.js, replacing the second line of the > function with > {code:javascript} > path = path.replace('//', '/').replace(':', '%3A'); > {code} > solves this specific issue, but it may cause other problems. What is the > correct way of handing URIs throughout the file plugin? -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org