avoid potential crashes when opening child databases (caused by network on main thread or URLs without username/password), fixes https://github.com/PhilippC/keepass2android/issues/728
This commit is contained in:
@@ -52,11 +52,9 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<LibraryProjectZip Include="..\java\android-filechooser-AS\app\build\outputs\aar\android-filechooser-release.aar">
|
|
||||||
<Link>Jars\android-filechooser-release.aar</Link>
|
|
||||||
</LibraryProjectZip>
|
|
||||||
<None Include="Jars\AboutJars.txt" />
|
<None Include="Jars\AboutJars.txt" />
|
||||||
<None Include="Additions\AboutAdditions.txt" />
|
<None Include="Additions\AboutAdditions.txt" />
|
||||||
|
<LibraryProjectZip Include="Jars\android-filechooser-debug.aar" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@@ -71,9 +71,18 @@ public class WebDavStorage extends JavaFileStorageBase {
|
|||||||
|
|
||||||
String scheme = filename.substring(0, filename.indexOf("://"));
|
String scheme = filename.substring(0, filename.indexOf("://"));
|
||||||
filename = filename.substring(scheme.length() + 3);
|
filename = filename.substring(scheme.length() + 3);
|
||||||
String userPwd = filename.substring(0, filename.indexOf('@'));
|
int idxAt = filename.indexOf('@');
|
||||||
ci.username = decode(userPwd.substring(0, userPwd.indexOf(":")));
|
if (idxAt >= 0)
|
||||||
ci.password = decode(userPwd.substring(userPwd.indexOf(":") + 1));
|
{
|
||||||
|
String userPwd = filename.substring(0, idxAt);
|
||||||
|
int idxColon = userPwd.indexOf(":");
|
||||||
|
if (idxColon >= 0);
|
||||||
|
{
|
||||||
|
ci.username = decode(userPwd.substring(0, idxColon));
|
||||||
|
ci.password = decode(userPwd.substring(idxColon + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ci.URL = scheme + "://" +filename.substring(filename.indexOf('@') + 1);
|
ci.URL = scheme + "://" +filename.substring(filename.indexOf('@') + 1);
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
|
@@ -335,9 +335,18 @@ namespace keepass2android
|
|||||||
|
|
||||||
private static bool CheckFileExsts(IOConnectionInfo ioc)
|
private static bool CheckFileExsts(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileStorage = App.Kp2a.GetFileStorage(ioc);
|
var fileStorage = App.Kp2a.GetFileStorage(ioc);
|
||||||
|
|
||||||
|
//we're assuming that remote files always exist (if we have a file storage, i.e. we check after receiving a file storage)
|
||||||
|
//The SkipIfNotExists switch only makes sense for local files, because remote files either exist for all devices or none
|
||||||
|
//(Ok, there are exceptions like files available in a (W)LAN. But then we still have the device switch and caches.)
|
||||||
|
//We cannot use OpenFileForRead on remote storages because this method is called from the main thread.
|
||||||
|
if (!ioc.IsLocalFile())
|
||||||
|
return true;
|
||||||
|
|
||||||
using (var stream = fileStorage.OpenFileForRead(ioc))
|
using (var stream = fileStorage.OpenFileForRead(ioc))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user