mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:25:11 +08:00
Issue #121: Problem with resolveLocalFileSystemURI if file name has spaces
This commit is contained in:
parent
05eacf4792
commit
ac2e92321f
@ -10,6 +10,7 @@ package com.phonegap;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
@ -229,15 +230,16 @@ public class FileUtils extends Plugin {
|
|||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
|
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
|
||||||
|
String decoded = URLDecoder.decode(url, "UTF-8");
|
||||||
// Test to see if this is a valid URL first
|
// Test to see if this is a valid URL first
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
URL testUrl = new URL(url);
|
URL testUrl = new URL(decoded);
|
||||||
|
|
||||||
File fp = null;
|
File fp = null;
|
||||||
if (url.startsWith("file://")) {
|
if (decoded.startsWith("file://")) {
|
||||||
fp = new File(url.substring(7, url.length()));
|
fp = new File(decoded.substring(7, decoded.length()));
|
||||||
} else {
|
} else {
|
||||||
fp = new File(url);
|
fp = new File(decoded);
|
||||||
}
|
}
|
||||||
if (!fp.exists()) {
|
if (!fp.exists()) {
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
|
Loading…
Reference in New Issue
Block a user