Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

What's new: media paths checked the same on every platform; the installer test knows --whats-new

KnifeLemon71ffcaee460e
diff --git a/src/Filee.App/Controls/SlideDeck.cs b/src/Filee.App/Controls/SlideDeck.cs
index 65b23f9b..4dbc96c1 100644
--- a/src/Filee.App/Controls/SlideDeck.cs
+++ b/src/Filee.App/Controls/SlideDeck.cs
@@ -80,7 +80,7 @@ public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
{
if (Text(item, "id") is { } id && Text(item, "media") is { } media
&& Text(item, "title") is { } title && Text(item, "text") is { } text
- && !media.Contains("..", StringComparison.Ordinal) && !Path.IsPathRooted(media))
+ && IsPlainRelative(media))
slides.Add(new Slide(id, new Uri(folder, media), title, text,
item.TryGetProperty("poster", out var poster) && poster.ValueKind == JsonValueKind.Number
&& poster.TryGetInt32(out var frame) && frame > 0 ? frame : 0));
@@ -106,6 +106,13 @@ public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
: null;
}
+ /// <summary>
+ /// A file name or path inside the deck's folder: not "..", not rooted ("/x", "\x") and no drive or scheme ("C:",
+ /// "https:"), whatever the platform the manifest is read on.
+ /// </summary>
+ private static bool IsPlainRelative(string media) =>
+ !media.Contains("..", StringComparison.Ordinal) && !media.Contains(':') && media[0] is not ('/' or '\\');
+
private static string? Text(JsonElement item, string name) =>
item.ValueKind == JsonValueKind.Object && item.TryGetProperty(name, out var value) && value.ValueKind == JsonValueKind.String
&& value.GetString() is { Length: > 0 } text ? text : null;
diff --git a/tests/Filee.App.Tests/InstallerTests.cs b/tests/Filee.App.Tests/InstallerTests.cs
index b3ca636a..dce2e2f8 100644
--- a/tests/Filee.App.Tests/InstallerTests.cs
+++ b/tests/Filee.App.Tests/InstallerTests.cs
@@ -31,7 +31,7 @@ public class InstallerTests
// Each option below is checked by a parse test; a new one in the script must be added here.
var used = Regex.Matches(Script, @"--[a-z][a-z-]+=?").Select(m => m.Value).ToHashSet();
Assert.Equal(
- new HashSet<string> { "--background", "--quit", "--uninstall-cleanup", "--install-engines=", "--start-with-windows=", "--context-menu=" },
+ new HashSet<string> { "--background", "--quit", "--uninstall-cleanup", "--install-engines=", "--start-with-windows=", "--context-menu=", "--whats-new" },
used);
}
diff --git a/tests/Filee.App.Tests/WhatsNewTests.cs b/tests/Filee.App.Tests/WhatsNewTests.cs
index 22d79662..7fb4e3e3 100644
--- a/tests/Filee.App.Tests/WhatsNewTests.cs
+++ b/tests/Filee.App.Tests/WhatsNewTests.cs
@@ -75,6 +75,8 @@ public class WhatsNewTests
{ "id": "no-text", "media": "two.webp", "title": "b.title" },
{ "id": "escape", "media": "../../secret.png", "title": "c.title", "text": "c.text" },
{ "id": "rooted", "media": "C:/x.png", "title": "d.title", "text": "d.text" },
+ { "id": "slash", "media": "/x.png", "title": "e.title", "text": "e.text" },
+ { "id": "web", "media": "https://example.com/x.png", "title": "f.title", "text": "f.text" },
],
}
""", folder);