mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Fix data URI decoding in CordovaResourceApi
It was not URI-decoding first, and so was broken for non-base64-encoded URIs.
This commit is contained in:
parent
fa366eb7a8
commit
4e1aa8aa59
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user