Allow `fromversion="*"` in dev tools
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 2 Mar 2022 12:55:45 +0000 (13:55 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 2 Mar 2022 12:56:26 +0000 (13:56 +0100)
Resolves #4659

ts/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/Instructions.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Form/Builder/Field/Devtools/Project/Instructions.js
wcfsetup/install/files/lib/system/form/builder/field/devtools/project/DevtoolsProjectInstructionsFormField.class.php

index 361d03bdd8d9474b1a81ddd376307b71386700f0..8f52e08e7f6c623625679b02b49f7c8c519114d6 100644 (file)
@@ -651,17 +651,13 @@ class Instructions {
       return false;
     }
 
-    // wildcard versions are checked on the server side
-    if (version.indexOf("*") === -1) {
-      if (!Instructions.versionRegExp.test(version)) {
+    // Allow either a single asterisk, an asterisk in the last digit or a regular version.
+    if (version !== '*') {
+      if (!Instructions.versionRegExp.test(version.replace(/\.\*$/, ".0"))) {
         DomUtil.innerError(inputField, Language.get("wcf.acp.devtools.project.packageVersion.error.format"));
 
         return false;
       }
-    } else if (!Instructions.versionRegExp.test(version.replace("*", "0"))) {
-      DomUtil.innerError(inputField, Language.get("wcf.acp.devtools.project.packageVersion.error.format"));
-
-      return false;
     }
 
     // remove outdated errors
index f3a62257e47561afa035d6a8e5c60cc76f4ee982..8d2695709be8d2fd7690a0312e5789ae6816737e 100644 (file)
@@ -484,17 +484,13 @@ define(["require", "exports", "tslib", "../../../../../../Core", "../../../../..
                 Util_1.default.innerError(inputField, Language.get("wcf.acp.devtools.project.packageVersion.error.maximumLength"));
                 return false;
             }
-            // wildcard versions are checked on the server side
-            if (version.indexOf("*") === -1) {
-                if (!Instructions.versionRegExp.test(version)) {
+            // Allow either a single asterisk, an asterisk in the last digit or a regular version.
+            if (version !== '*') {
+                if (!Instructions.versionRegExp.test(version.replace(/\.\*$/, ".0"))) {
                     Util_1.default.innerError(inputField, Language.get("wcf.acp.devtools.project.packageVersion.error.format"));
                     return false;
                 }
             }
-            else if (!Instructions.versionRegExp.test(version.replace("*", "0"))) {
-                Util_1.default.innerError(inputField, Language.get("wcf.acp.devtools.project.packageVersion.error.format"));
-                return false;
-            }
             // remove outdated errors
             Util_1.default.innerError(inputField, "");
             return true;
index 01281db69ad17d92ac5a9545ca1ae85c29832518..476825b0f5240ca79fe08a3eac735cd1be91a90d 100644 (file)
@@ -5,7 +5,6 @@ namespace wcf\system\form\builder\field\devtools\project;
 use wcf\data\application\Application;
 use wcf\data\package\installation\plugin\PackageInstallationPlugin;
 use wcf\data\package\installation\plugin\PackageInstallationPluginList;
-use wcf\data\package\Package;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\form\builder\field\AbstractFormField;
 use wcf\system\form\builder\field\TDefaultIdFormField;
@@ -173,13 +172,11 @@ class DevtoolsProjectInstructionsFormField extends AbstractFormField
                     return false;
                 }
 
-                if (\strpos($instructions['fromVersion'], '*') !== false) {
-                    if (!Package::isValidVersion(\str_replace('*', '0', $instructions['fromVersion']))) {
-                        return false;
-                    }
-                } elseif (!Package::isValidVersion($instructions['fromVersion'])) {
-                    return false;
-                }
+                // Do not validate the actual version. The actual installation process
+                // does not validate it either and we should not *silently* drop uncommon
+                // (but valid) formats.
+                // The JavaScript validation should be sufficient to nudge the user
+                // into the correct direction.
             }
 
             foreach ($instructions['instructions'] as $instruction) {