cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: Fix data URI decoding in CordovaResourceApi
Date Tue, 13 Aug 2013 18:11:48 GMT
Updated Branches:
  refs/heads/master fa366eb7a -> 4e1aa8aa5


Fix data URI decoding in CordovaResourceApi

It was not URI-decoding first, and so was broken for non-base64-encoded
URIs.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4e1aa8aa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4e1aa8aa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4e1aa8aa

Branch: refs/heads/master
Commit: 4e1aa8aa59d0a3d9c0deb1f57c9136a76535691e
Parents: fa366eb
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Aug 13 14:08:30 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Aug 13 14:11:40 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaResourceApi.java     | 2 +-
 test/src/org/apache/cordova/test/CordovaResourceApiTest.java | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4e1aa8aa/framework/src/org/apache/cordova/CordovaResourceApi.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java
index cb85744..f03f1b5 100644
--- a/framework/src/org/apache/cordova/CordovaResourceApi.java
+++ b/framework/src/org/apache/cordova/CordovaResourceApi.java
@@ -315,7 +315,7 @@ public class CordovaResourceApi {
     }
     
     private OpenForReadResult readDataUri(Uri uri) {
-        String uriAsString = uri.toString().substring(5);
+        String uriAsString = uri.getSchemeSpecificPart();
         int commaPos = uriAsString.indexOf(',');
         if (commaPos == -1) {
             return null;

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4e1aa8aa/test/src/org/apache/cordova/test/CordovaResourceApiTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaResourceApiTest.java b/test/src/org/apache/cordova/test/CordovaResourceApiTest.java
index fdaf972..1078a4e 100644
--- a/test/src/org/apache/cordova/test/CordovaResourceApiTest.java
+++ b/test/src/org/apache/cordova/test/CordovaResourceApiTest.java
@@ -223,11 +223,11 @@ public class CordovaResourceApiTest extends ActivityInstrumentationTestCase2<Cor
     
     public void testDataUriPlain() throws IOException
     {
-        Uri uri = Uri.parse("data:text/plain;charset=utf-8,pass");
+        Uri uri = Uri.parse("data:text/plain;charset=utf-8,pa%20ss");
         OpenForReadResult readResult = resourceApi.openForRead(uri);
         assertEquals("text/plain", readResult.mimeType);
         String data = new Scanner(readResult.inputStream, "UTF-8").useDelimiter("\\A").next();
-        assertEquals("pass", data);
+        assertEquals("pa ss", data);
     }
     
     public void testDataUriBase64() throws IOException


Mime
View raw message