summaryrefslogtreecommitdiffstats
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>2023-07-13 11:07:03 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-07-18 16:57:15 +0200
commitc46f5680ca8d911c5e83c90b73f830f4f4609686 (patch)
treef1a71a56a93c86a2e7ff9cc1058655723f198cba /src/basic/string-util.c
parentRevert "packit: temporarily use older Rawhide spec" (diff)
downloadsystemd-c46f5680ca8d911c5e83c90b73f830f4f4609686.tar.xz
systemd-c46f5680ca8d911c5e83c90b73f830f4f4609686.zip
analyze: don't warn about version spec compliant versions
This commits adds version_is_valid_versionspec and uses it in analyze-compare-version.c. version_is_valid_versionspec differs from version_is_valid in that it acepts empty strings and since valid characters in a version spec version are all ASCII letters and digits as well as "-.~^", but ",_+" allowed by version_is_valid are not. Also give a more specific warning message on invalid characters.
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index d3b6db9c55..7cddec712b 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -1436,3 +1436,13 @@ bool version_is_valid(const char *s) {
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;
+}