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.

Read PowerShell scripts (.ps1) as plain text (#442, #455)

cre8ive-marketing18f56d7d71c3
diff --git a/docs/ENGINES.md b/docs/ENGINES.md
index 7add95c5..b81b7ad1 100644
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@ -12,7 +12,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,
| PDFsharp | built in (library) | images → PDF, merge, split, page ranges, **compression** (smaller PDFs, see below), PDFs without their metadata |
| PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported) |
| Unhwp | built in (library) | HWP/HWPX → TXT, Markdown, HTML (pictures in a `<name>_files` folder next to the Markdown, embedded in the HTML) |
-| Text & Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT**; **TXT, LOG, PY, PAC, BAT, COMMAND, LUA, CSS → UTF-8 TXT**, preserving source text without running scripts (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
+| Text & Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT**; **TXT, LOG, PY, PAC, BAT, COMMAND, LUA, CSS, PS1 → UTF-8 TXT**, preserving source text without running scripts (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
| Spreadsheets (ExcelDataReader for XLS) | built in (library) | **XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV** (one CSV / TSV per sheet) |
| Office Open XML | built in | **DOCM / DOTX / DOTM ↔ DOCX, XLSM / XLTX ↔ XLSX, PPTM / POTX / POTM / PPSX ↔ PPTX** (macros removed for macro-free types) |
| Fonts | built in | **TTF, OTF, WOFF, WOFF2, EOT ↔ each other**; CFF (PostScript) outlines become TrueType for TTF and EOT |
diff --git a/src/Filee.Core/Formats/FormatRegistry.cs b/src/Filee.Core/Formats/FormatRegistry.cs
index ba30df55..9c05ac9e 100644
--- a/src/Filee.Core/Formats/FormatRegistry.cs
+++ b/src/Filee.Core/Formats/FormatRegistry.cs
@@ -139,7 +139,7 @@ public static class FormatRegistry
// Plain text / markup
// Text logs, source/proxy scripts and style sheets are read as plain text, never executed (issues #273, #284, #254,
// #388, #368).
- new("txt", "TXT", FormatCategory.Text, ["txt", "log", "py", "pac", "bat", "command", "lua", "css"]),
+ new("txt", "TXT", FormatCategory.Text, ["txt", "log", "py", "pac", "bat", "command", "lua", "css", "ps1"]),
new("md", "Markdown", FormatCategory.Text, ["md", "markdown"]),
new("html", "HTML", FormatCategory.Text, ["html", "htm", "xhtml"]),
// A web page saved with its pictures in one MIME file (Chrome, Edge, Word); read as the page it holds.
diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.cs
index 1e4cbe88..c9856e03 100644
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@ -112,7 +112,7 @@ public sealed class DonutSettings
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
- public const int CurrentSchemaVersion = 38;
+ public const int CurrentSchemaVersion = 39;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.cs
index 885ddb08..6b8aa4d8 100644
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@ -794,6 +794,9 @@ internal static class SettingsMigrations
// v38: Tajima embroidery designs (.dst) learn the vector donut; custom claims stay put.
if (from < 38)
changed |= LearnExtensions(profiles, out _, ["dst"]);
+ // v39: PowerShell scripts (.ps1) learn the text donut; custom claims stay put.
+ if (from < 39)
+ changed |= LearnExtensions(profiles, out _, ["ps1"]);
return changed;
}
diff --git a/tests/Filee.Core.Tests/ScriptTextTests.cs b/tests/Filee.Core.Tests/ScriptTextTests.cs
index ad482f63..00ee33b3 100644
--- a/tests/Filee.Core.Tests/ScriptTextTests.cs
+++ b/tests/Filee.Core.Tests/ScriptTextTests.cs
@@ -1,4 +1,5 @@
-// Lua scripts and CSS style sheets are plain text (issues #388, #368): recognised, and learnt by existing text donuts.
+// Lua and PowerShell scripts and CSS style sheets are plain text (issues #388, #368, #442): recognised, and learnt by
+// existing text donuts.
using Filee.Core.Formats;
using Filee.Core.Presets;
@@ -12,6 +13,7 @@ public class ScriptTextTests
[Theory]
[InlineData("init.lua")]
[InlineData("site.css")]
+ [InlineData("Backup.ps1")]
public void Scripts_and_style_sheets_are_text(string name) => Assert.Equal("txt", FormatRegistry.Detect(name)?.Id);
[Fact]
@@ -30,4 +32,18 @@ public class ScriptTextTests
Assert.DoesNotContain("css", text); // the user's own donut has it
Assert.False(SettingsMigrations.ApplyToLibrary(33, presets, profiles));
}
+
+ [Fact]
+ public void Version_38_text_donuts_learn_powershell_scripts()
+ {
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles();
+ foreach (var profile in profiles)
+ profile.Extensions.Remove("ps1");
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(38, presets, profiles));
+
+ Assert.Contains("ps1", profiles.Single(p => p.Id == "text").Extensions);
+ Assert.False(SettingsMigrations.ApplyToLibrary(39, presets, profiles));
+ }
}