Skip to content

Commit f19670a

Browse files
committed
Fix for bug 2467152 files with spaces fail to open.
from http://code.google.com/p/android/issues/detail?id=4638 If you try to use a WebView to open an image (of any type) that is stored in your project's assets/ directory the image will be written to the screen as text (instead of drawn as an image) if the filename contains a space. The problem stems from MimeTypeMap, which determines the file type from the url. Spaces, represented as '%20' are not included in the list of acceptable characters for an image file name, causing the image to be treated as plain text. I am remedying this by adding '%' to the list. Change-Id: I29e3da57f3cdaa63ed60b1e6977ba62a0dd108e5
1 parent 42b21c3 commit f19670a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/java/android/webkit/MimeTypeMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static String getFileExtensionFromUrl(String url) {
6767
// if the filename contains special characters, we don't
6868
// consider it valid for our matching purposes:
6969
if (filename.length() > 0 &&
70-
Pattern.matches("[a-zA-Z_0-9\\.\\-\\(\\)]+", filename)) {
70+
Pattern.matches("[a-zA-Z_0-9\\.\\-\\(\\)\\%]+", filename)) {
7171
int dotPos = filename.lastIndexOf('.');
7272
if (0 <= dotPos) {
7373
return filename.substring(dotPos + 1);

0 commit comments

Comments
 (0)