mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-17 23:40:23 -05:00
added check in verification of paths to throw FileNotFound for invalid paths without id and if the display name doesn't match the id
This commit is contained in:
parent
30de7e80b6
commit
8f01199930
@ -139,7 +139,7 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//make sure the path exists
|
//make sure the path exists
|
||||||
private void verify() throws FileNotFoundException {
|
private void verify() throws FileNotFoundException, UnsupportedEncodingException {
|
||||||
|
|
||||||
if (mAccountLocalPath.equals(""))
|
if (mAccountLocalPath.equals(""))
|
||||||
return;
|
return;
|
||||||
@ -151,12 +151,18 @@ public class GoogleDriveFileStorage implements JavaFileStorage {
|
|||||||
String parentId = accountData.mRootFolderId;
|
String parentId = accountData.mRootFolderId;
|
||||||
for (String part: parts)
|
for (String part: parts)
|
||||||
{
|
{
|
||||||
String id = part.substring(part.lastIndexOf(NAME_ID_SEP)+NAME_ID_SEP.length());
|
int indexOfSeparator = part.lastIndexOf(NAME_ID_SEP);
|
||||||
|
if (indexOfSeparator < 0)
|
||||||
|
throw new FileNotFoundException("invalid path " + mAccountLocalPath);
|
||||||
|
String id = part.substring(indexOfSeparator+NAME_ID_SEP.length());
|
||||||
|
String name = decode(part.substring(0, indexOfSeparator));
|
||||||
FileSystemEntryData thisFolder = accountData.mFileSystemEntryCache.get(id);
|
FileSystemEntryData thisFolder = accountData.mFileSystemEntryCache.get(id);
|
||||||
if (thisFolder == null)
|
if (thisFolder == null)
|
||||||
throw new FileNotFoundException("couldn't find id " + id + " being part of "+ mAccountLocalPath+" in GDrive account " + mAccount);
|
throw new FileNotFoundException("couldn't find id " + id + " being part of "+ mAccountLocalPath+" in GDrive account " + mAccount);
|
||||||
if (thisFolder.parentIds.contains(parentId) == false)
|
if (thisFolder.parentIds.contains(parentId) == false)
|
||||||
throw new FileNotFoundException("couldn't find parent id " + parentId + " as parent of "+thisFolder.displayName +" in "+ mAccountLocalPath+" in GDrive account " + mAccount);
|
throw new FileNotFoundException("couldn't find parent id " + parentId + " as parent of "+thisFolder.displayName +" in "+ mAccountLocalPath+" in GDrive account " + mAccount);
|
||||||
|
if (thisFolder.displayName.equals(name) == false)
|
||||||
|
throw new FileNotFoundException("Name of "+id+" changed from "+name+" to "+thisFolder.displayName +" in "+ mAccountLocalPath+" in GDrive account " + mAccount);
|
||||||
|
|
||||||
parentId = id;
|
parentId = id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user