mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3659 from Flow-Launcher/firefox_index_out_of_range
Check index out of range for FireFox
This commit is contained in:
commit
dbd5e2c289
1 changed files with 41 additions and 2 deletions
|
|
@ -270,6 +270,7 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase
|
|||
/// <summary>
|
||||
/// Path to places.sqlite
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
private static string PlacesPath
|
||||
{
|
||||
get
|
||||
|
|
@ -295,12 +296,50 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase
|
|||
|
||||
var indexOfDefaultProfileAttributePath = lines.IndexOf("Path=" + defaultProfileFolderName);
|
||||
|
||||
/*
|
||||
Current profiles.ini structure example as of Firefox version 69.0.1
|
||||
|
||||
[Install736426B0AF4A39CB]
|
||||
Default=Profiles/7789f565.default-release <== this is the default profile this plugin will get the bookmarks from. When opened Firefox will load the default profile
|
||||
Locked=1
|
||||
|
||||
[Profile2]
|
||||
Name=newblahprofile
|
||||
IsRelative=0
|
||||
Path=C:\t6h2yuq8.newblahprofile <== Note this is a custom location path for the profile user can set, we need to cater for this in code.
|
||||
|
||||
[Profile1]
|
||||
Name=default
|
||||
IsRelative=1
|
||||
Path=Profiles/cydum7q4.default
|
||||
Default=1
|
||||
|
||||
[Profile0]
|
||||
Name=default-release
|
||||
IsRelative=1
|
||||
Path=Profiles/7789f565.default-release
|
||||
|
||||
[General]
|
||||
StartWithLastProfile=1
|
||||
Version=2
|
||||
*/
|
||||
// Seen in the example above, the IsRelative attribute is always above the Path attribute
|
||||
|
||||
var relativePath = Path.Combine(defaultProfileFolderName, "places.sqlite");
|
||||
var absoluePath = Path.Combine(profileFolderPath, relativePath);
|
||||
|
||||
// If the index is out of range, it means that the default profile is in a custom location or the file is malformed
|
||||
// If the profile is in a custom location, we need to check
|
||||
if (indexOfDefaultProfileAttributePath - 1 < 0 ||
|
||||
indexOfDefaultProfileAttributePath - 1 >= lines.Count)
|
||||
{
|
||||
return Directory.Exists(absoluePath) ? absoluePath : relativePath;
|
||||
}
|
||||
|
||||
var relativeAttribute = lines[indexOfDefaultProfileAttributePath - 1];
|
||||
|
||||
return relativeAttribute == "0" // See above, the profile is located in a custom location, path is not relative, so IsRelative=0
|
||||
? defaultProfileFolderName + @"\places.sqlite"
|
||||
: Path.Combine(profileFolderPath, defaultProfileFolderName) + @"\places.sqlite";
|
||||
? relativePath : absoluePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue