Progmasoft Git

progmaweb

The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.

Clonegit clone https://git.progmasoft.com/progmaweb

Anchor the identity patterns at the end of the text

In .NET, $ also matches before a final line break, so a name or version
ending in one passed the check and was kept with it, giving a catalog entry
and a JAR path the public route never matches. The patterns end in \z.
Commit
4dbeff2eea0fd2e0ad4c6da3d41f902dcdcf50ce
Author
Leitwolf11 ·
Parents
4a00a68309a3

Files · Download .tar.gz

Changes

 apps/api-tests/ViGetTests.cs            | 6 ++++++
 apps/api/ViGet/TazelPluginDescriptor.cs | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/apps/api-tests/ViGetTests.cs b/apps/api-tests/ViGetTests.cs
index 2037d30..0d39da5 100644
--- a/apps/api-tests/ViGetTests.cs
+++ b/apps/api-tests/ViGetTests.cs
@@ -70,6 +70,12 @@ public sealed class ViGetTests : IDisposable
             TazelPluginDescriptor.TryRead(Jar(), "Progmasoft", "c-make", "0.1.0", out _));
         Assert.Equal("The publisher must be one identifier.",
             TazelPluginDescriptor.TryRead(Jar(), "Progma soft", "CMake", "0.1.0", out _));
+        // A line break after the name or the version is not part of either.
+        Assert.Equal("The name of the plugin must be one identifier.",
+            TazelPluginDescriptor.TryRead(Jar(), "Progmasoft", "CMake\n", "0.1.0", out _));
+        Assert.Equal("The version must be exact, of three to five numbers.",
+            TazelPluginDescriptor.TryRead(Jar(), "Progmasoft", "CMake", "0.1.0\n", out _));
+        Assert.False(TazelPluginDescriptor.IsVersion("0.1.0\n"));
         Assert.Equal("The homepage of the descriptor is not an https address.",
             Read(Jar(homepage: "http\\://example.com"), out _));
         Assert.Equal("The file is not a JAR.", Read("not a zip"u8.ToArray(), out _));
diff --git a/apps/api/ViGet/TazelPluginDescriptor.cs b/apps/api/ViGet/TazelPluginDescriptor.cs
index 7cf3ca1..6fb4eb8 100644
--- a/apps/api/ViGet/TazelPluginDescriptor.cs
+++ b/apps/api/ViGet/TazelPluginDescriptor.cs
@@ -140,11 +140,11 @@ internal sealed partial record TazelPluginDescriptor(
 
     /// <summary>One identifier: a letter or <c>_</c>, then letters, digits or <c>_</c>.</summary>
     /// <returns>The compiled expression.</returns>
-    [GeneratedRegex("^[A-Za-z_][A-Za-z0-9_]*$")]
+    [GeneratedRegex(@"^[A-Za-z_][A-Za-z0-9_]*\z")]
     private static partial Regex IdentifierPattern();
 
     /// <summary>An exact version of three to five numbers without leading zeros, as Tazel accepts it.</summary>
     /// <returns>The compiled expression.</returns>
-    [GeneratedRegex(@"^(?:0|[1-9][0-9]*)(?:\.(?:0|[1-9][0-9]*)){2,4}(?:-[0-9A-Za-z.-]+)?$")]
+    [GeneratedRegex(@"^(?:0|[1-9][0-9]*)(?:\.(?:0|[1-9][0-9]*)){2,4}(?:-[0-9A-Za-z.-]+)?\z")]
     private static partial Regex VersionPattern();
 }