summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-utils.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-10-26 12:01:08 +0000
committerRichard Hughes <richard@hughsie.com>2015-10-26 12:01:08 +0000
commit973119c56488ab679f093ce7c2e99b4d06acc3e0 (patch)
treea842207970168017d6f2b527223a9eb0437dab2b /libappstream-glib/as-utils.c
parentc60e682baffc86c6ed85b77960fe0a17d62f67ea (diff)
downloadappstream-glib-973119c56488ab679f093ce7c2e99b4d06acc3e0.tar.gz
libappstream-glib: Do not parse ISO dates as uint32 version numbers
Diffstat (limited to 'libappstream-glib/as-utils.c')
-rw-r--r--libappstream-glib/as-utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 5621982..53d9e82 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -1700,6 +1700,7 @@ as_utils_version_from_uint32 (guint32 val, AsVersionParseFlag flags)
* - Dotted decimal, e.g. "1.2.3"
* - Base 16, a hex number *with* a 0x prefix, e.g. "0x10203"
* - Base 10, a string containing just [0-9], e.g. "66051"
+ * - Date in YYYYMMDD format, e.g. 20150915
*
* Anything with a '.' or that doesn't match [0-9] or 0x[a-f,0-9] is considered
* a string and returned without modification.
@@ -1720,6 +1721,11 @@ as_utils_version_parse (const gchar *version)
if (g_strstr_len (version, -1, ".") != NULL)
return g_strdup (version);
+ /* is a date */
+ if (g_str_has_prefix (version, "20") &&
+ strlen (version) == 8)
+ return g_strdup (version);
+
/* convert 0x prefixed strings to dotted decimal */
if (g_str_has_prefix (version, "0x")) {
version += 2;