assert(argv);
/* We only output a warning on invalid version strings (instead of failing), since the comparison
- * functions try to handle invalid strings graceful and it's still interesting to see what the
+ * functions try to handle invalid strings gracefully and it's still interesting to see what the
* comparison result will be. */
- if (!version_is_valid(v1))
- log_warning("Version string 1 is not valid, comparing anyway: %s", v1);
- if (!version_is_valid(v2))
- log_warning("Version string 2 is not valid, comparing anyway: %s", v2);
+ if (!version_is_valid_versionspec(v1))
+ log_warning("Version string 1 contains disallowed characters, they will be treated as separators: %s", v1);
+ if (!version_is_valid_versionspec(v2))
+ log_warning("Version string 2 contains disallowed characters, they will be treated as separators: %s", v2);
if (argc == 3) {
r = strverscmp_improved(v1, v2);
return true;
}
+
+bool version_is_valid_versionspec(const char *s) {
+ if (!filename_part_is_valid(s))
+ return false;
+
+ if (!in_charset(s, ALPHANUMERICAL "-.~^"))
+ return false;
+
+ return true;
+}
startswith_strv(p, STRV_MAKE(__VA_ARGS__))
bool version_is_valid(const char *s);
+
+bool version_is_valid_versionspec(const char *s);