Skip to content

Commit 79d35bb

Browse files
committed
Check index before returning PlacesPath
1 parent 1697544 commit 79d35bb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,22 @@ Current profiles.ini structure example as of Firefox version 69.0.1
324324
Version=2
325325
*/
326326
// Seen in the example above, the IsRelative attribute is always above the Path attribute
327+
328+
var relativePath = Path.Combine(defaultProfileFolderName, "places.sqlite");
329+
var absoluePath = Path.Combine(profileFolderPath, relativePath);
330+
331+
// If the index is out of range, it means that the default profile is in a custom location or the file is malformed
332+
// If the profile is in a custom location, we need to check
333+
if (indexOfDefaultProfileAttributePath - 1 < 0 ||
334+
indexOfDefaultProfileAttributePath - 1 >= lines.Count)
335+
{
336+
return Directory.Exists(absoluePath) ? absoluePath : relativePath;
337+
}
338+
327339
var relativeAttribute = lines[indexOfDefaultProfileAttributePath - 1];
328340

329341
return relativeAttribute == "0" // See above, the profile is located in a custom location, path is not relative, so IsRelative=0
330-
? defaultProfileFolderName + @"\places.sqlite"
331-
: Path.Combine(profileFolderPath, defaultProfileFolderName) + @"\places.sqlite";
342+
? relativePath : absoluePath;
332343
}
333344
}
334345
}

0 commit comments

Comments
 (0)