mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 16:43:26 +02:00
Sanitize incoming attachment mime type
This commit is contained in:
@@ -52,6 +52,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
@@ -647,6 +648,20 @@ public class Helper {
|
||||
return filename.substring(index + 1);
|
||||
}
|
||||
|
||||
static String guessMimeType(String filename) {
|
||||
String type = null;
|
||||
|
||||
String extension = Helper.getExtension(filename);
|
||||
if (extension != null)
|
||||
type = MimeTypeMap.getSingleton()
|
||||
.getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (TextUtils.isEmpty(type))
|
||||
type = "application/octet-stream";
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void writeText(File file, String content) throws IOException {
|
||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||
if (content != null)
|
||||
|
||||
Reference in New Issue
Block a user