diff options
| author | Leitwolf11 | 2026-11-06 02:45:48 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-06 02:45:48 +0300 |
| commit | 4dbeff2eea0fd2e0ad4c6da3d41f902dcdcf50ce (patch) | |
| tree | 357ed1d6650f9589c9d6f53d4ba9a7d27981e434 /apps | |
| parent | 4a00a68309a3605dafedbc522569fc1b2c8aca1e (diff) | |
| download | progmaweb-feature/plugin-identity-from-command.tar.gz | |
Anchor the identity patterns at the end of the textfeature/plugin-identity-from-command
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.
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/api-tests/ViGetTests.cs | 6 | ||||
| -rw-r--r-- | 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(); } |