mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 638940 - File Upload: we should not change file names, paths and extensions r=dougt
This commit is contained in:
parent
e9f85ae1c1
commit
ec9c2d5c92
@ -59,6 +59,8 @@ import android.hardware.*;
|
||||
|
||||
import android.util.*;
|
||||
import android.net.*;
|
||||
import android.database.*;
|
||||
import android.provider.*;
|
||||
|
||||
abstract public class GeckoApp
|
||||
extends Activity
|
||||
@ -654,13 +656,33 @@ abstract public class GeckoApp
|
||||
try {
|
||||
ContentResolver cr = getContentResolver();
|
||||
Uri uri = data.getData();
|
||||
String mimeType = cr.getType(uri);
|
||||
String fileExt = "." +
|
||||
GeckoAppShell.getExtensionFromMimeType(mimeType);
|
||||
File file =
|
||||
File.createTempFile("tmp_" +
|
||||
(int)Math.floor(1000 * Math.random()),
|
||||
fileExt, sGREDir);
|
||||
Cursor cursor = GeckoApp.mAppContext.getContentResolver().query(
|
||||
uri,
|
||||
new String[] { OpenableColumns.DISPLAY_NAME },
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
String name = null;
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.moveToNext()) {
|
||||
name = cursor.getString(0);
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
String fileName = "tmp_";
|
||||
String fileExt = null;
|
||||
int period;
|
||||
if (name == null || (period = name.lastIndexOf('.')) == -1) {
|
||||
String mimeType = cr.getType(uri);
|
||||
fileExt = "." + GeckoAppShell.getExtensionFromMimeType(mimeType);
|
||||
} else {
|
||||
fileExt = name.substring(period);
|
||||
fileName = name.substring(0, period);
|
||||
}
|
||||
File file = File.createTempFile(fileName, fileExt, sGREDir);
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
InputStream is = cr.openInputStream(uri);
|
||||
|
Loading…
Reference in New Issue
Block a user