fix issue with opening attachments with special characters in their name, closes #480

This commit is contained in:
Philipp Crocoll
2018-09-11 21:42:44 +02:00
parent dbba098555
commit d4936e8eec

View File

@@ -30,6 +30,7 @@ using Android.Widget;
using Android.Preferences;
using Android.Text.Method;
using System.Globalization;
using System.Net;
using Android.Content.PM;
using Android.Webkit;
using Android.Graphics;
@@ -540,9 +541,12 @@ namespace keepass2android
binaryDirectory = CacheDir.Path + File.Separator + AttachmentContentProvider.AttachmentCacheSubDir;
string filepart = key;
if (writeToCacheDirectory)
filepart = filepart.Replace(" ", "");
var targetFile = new File(binaryDirectory, filepart);
if (writeToCacheDirectory)
{
Java.Lang.String javaFilename = new Java.Lang.String(filepart);
filepart = javaFilename.ReplaceAll("[^a-zA-Z0-9.-]", "_");
}
var targetFile = new File(binaryDirectory, filepart);
File parent = targetFile.ParentFile;