make sure AutoExec items with unknown protocols don't crash the app, closes #1452
This commit is contained in:
@@ -1981,8 +1981,18 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeFilenameView() {
|
private void InitializeFilenameView()
|
||||||
SetEditText(Resource.Id.filename, App.Kp2a.GetFileStorage(_ioConnection).GetDisplayName(_ioConnection));
|
{
|
||||||
|
string filenameToShow = _ioConnection.Path;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
filenameToShow = App.Kp2a.GetFileStorage(_ioConnection).GetDisplayName(_ioConnection);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Kp2aLog.LogUnexpectedError(e);
|
||||||
|
}
|
||||||
|
SetEditText(Resource.Id.filename, filenameToShow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,22 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
private int ReqCodeOpenNewDb = 1;
|
private int ReqCodeOpenNewDb = 1;
|
||||||
|
|
||||||
|
private static bool IsValidIoc(AutoExecItem item)
|
||||||
|
{
|
||||||
|
IOConnectionInfo itemIoc;
|
||||||
|
if (!KeeAutoExecExt.TryGetDatabaseIoc(item, out itemIoc))
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//see if we have a file storage for the given protocol
|
||||||
|
App.Kp2a.GetFileStorage(itemIoc);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public class OpenDatabaseAdapter : BaseAdapter
|
public class OpenDatabaseAdapter : BaseAdapter
|
||||||
{
|
{
|
||||||
@@ -164,9 +180,15 @@ namespace keepass2android
|
|||||||
IOConnectionInfo itemIoc;
|
IOConnectionInfo itemIoc;
|
||||||
return KeeAutoExecExt.TryGetDatabaseIoc(item, out itemIoc) &&
|
return KeeAutoExecExt.TryGetDatabaseIoc(item, out itemIoc) &&
|
||||||
displayedDb.Ioc.IsSameFileAs(itemIoc);
|
displayedDb.Ioc.IsSameFileAs(itemIoc);
|
||||||
}))
|
})
|
||||||
|
&& IsValidIoc(item)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAutoExecItemSelected(AutoExecItem autoExecItem)
|
private void OnAutoExecItemSelected(AutoExecItem autoExecItem)
|
||||||
@@ -438,6 +460,9 @@ namespace keepass2android
|
|||||||
continue;
|
continue;
|
||||||
if (!KeeAutoExecExt.IsDeviceEnabled(autoOpenItem, thisDevice, out _))
|
if (!KeeAutoExecExt.IsDeviceEnabled(autoOpenItem, thisDevice, out _))
|
||||||
continue;
|
continue;
|
||||||
|
if (!IsValidIoc(autoOpenItem))
|
||||||
|
continue;
|
||||||
|
|
||||||
IOConnectionInfo dbIoc;
|
IOConnectionInfo dbIoc;
|
||||||
if (KeeAutoExecExt.TryGetDatabaseIoc(autoOpenItem, out dbIoc) &&
|
if (KeeAutoExecExt.TryGetDatabaseIoc(autoOpenItem, out dbIoc) &&
|
||||||
App.Kp2a.TryGetDatabase(dbIoc) == null &&
|
App.Kp2a.TryGetDatabase(dbIoc) == null &&
|
||||||
|
|||||||
Reference in New Issue
Block a user