Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Flow.Launcher.Test/Flow.Launcher.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Program\Flow.Launcher.Plugin.Program.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Shell\Flow.Launcher.Plugin.Shell.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Url\Flow.Launcher.Plugin.Url.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.BrowserBookmark\Flow.Launcher.Plugin.BrowserBookmark.csproj" />
<ProjectReference Include="..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
<ProjectReference Include="..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
Expand Down
55 changes: 55 additions & 0 deletions Flow.Launcher.Test/Plugins/BrowserBookmarkPluginTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.IO;
using System.Reflection;
using Flow.Launcher.Plugin.BrowserBookmark;
using NUnit.Framework;

namespace Flow.Launcher.Test.Plugins
{
[TestFixture]
public class BrowserBookmarkPluginTest
{
[TestCase("\n")]
[TestCase("\r\n")]
public void GetProfileIniPath_ParsesDefaultProfileWithDifferentLineEndings(string newline)
{
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(tempDir);

try
{
var profileRoot = Path.Combine(tempDir, "Mozilla", "Firefox");
Directory.CreateDirectory(profileRoot);

var defaultProfile = "Profiles/7789f565.default-release";
var lines = new[]
{
"[Install736426B0AF4A39CB]",
$"Default={defaultProfile}",
"Locked=1",
string.Empty,
"[Profile0]",
"Name=default-release",
"IsRelative=1",
$"Path={defaultProfile}"
};

File.WriteAllText(Path.Combine(profileRoot, "profiles.ini"), string.Join(newline, lines));

var method = typeof(FirefoxBookmarkLoader).GetMethod("GetProfileIniPath",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.That(method, Is.Not.Null);

var path = method.Invoke(null, new object[] { profileRoot }) as string;
var expected = Path.Combine(profileRoot, defaultProfile, "places.sqlite");

Assert.That(path, Is.EqualTo(expected));
}
finally
{
if (Directory.Exists(tempDir))
Directory.Delete(tempDir, true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,7 @@ private static string GetProfileIniPath(string profileFolderPath)
return string.Empty;

// get firefox default profile directory from profiles.ini
using var sReader = new StreamReader(profileIni);
var ini = sReader.ReadToEnd();

var lines = ini.Split("\r\n").ToList();
var lines = File.ReadAllLines(profileIni).ToList();

var defaultProfileFolderNameRaw = lines.FirstOrDefault(x => x.Contains("Default=") && x != "Default=1") ?? string.Empty;

Expand Down