From 79d35bba5f398562fcde4ffea6ac9f70fa5a9004 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 5 Jun 2025 22:54:34 +0800 Subject: [PATCH] Check index before returning PlacesPath --- .../FirefoxBookmarkLoader.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs index f3b4c109f..acace2506 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs @@ -324,11 +324,22 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase 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; } } }