aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Lobrano <carlo.lobrano@telit.com>2022-04-11 17:52:25 +0200
committerCarlo Lobrano <carlo.lobrano@telit.com>2022-04-12 08:46:29 +0200
commit0645b70aeae7334bba1d301f2baf1f71e822c3af (patch)
tree87d104dcf8d96c026c27b071385a586ba1f2dc2c
parent818b539d651eadb9ceb9faf81cec442bdbac74a3 (diff)
plugins,telit: SWPKGV parsing needs more permissive regex
In some cases the "base" software package string does not have the currently expected format of \d{2}.\d{2}.\d{3}. Specifically the last triplet of characters might not be digits. For example a valid version string might be 25.20.-04, which the current regex is unable to parse. This change replace the previous regex with one less restrictive, checking only the first part of the version's format.
-rw-r--r--plugins/telit/mm-modem-helpers-telit.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c
index ba9a3a70..767548ca 100644
--- a/plugins/telit/mm-modem-helpers-telit.c
+++ b/plugins/telit/mm-modem-helpers-telit.c
@@ -898,19 +898,12 @@ mm_telit_parse_swpkgv_response (const gchar *response)
{
gchar *version = NULL;
g_autofree gchar *base_version = NULL;
- g_autofree gchar *ext_version = NULL;
- g_autofree gchar *production_version = NULL;
g_autoptr(GRegex) r = NULL;
g_autoptr(GMatchInfo) match_info = NULL;
guint matches;
- /* We are interested only in the first line: "Telit Software Package version"
- * which is composed by up to three parts:
- * - base version: "ab.cde.fgh"
- * - extended version (e.g. alpha, beta, test version): "Axyz", "Bxyz", or "Txyz"
- * - production parameter version (e.g. P0F.012345)
- */
- r = g_regex_new ("(?P<Base>\\d{2}.\\d{2}.\\d{3})(?P<Ext>-[ABT]\\d{3})?(?P<Prod>-\\w\\d\\w\\.\\d+)?",
+ /* We are interested only in the first line of the response */
+ r = g_regex_new ("(?P<Base>\\d{2}.\\d{2}.*)",
G_REGEX_RAW | G_REGEX_MULTILINE | G_REGEX_NEWLINE_CRLF,
G_REGEX_MATCH_NEWLINE_CR,
NULL);
@@ -926,17 +919,8 @@ mm_telit_parse_swpkgv_response (const gchar *response)
}
base_version = g_match_info_fetch_named (match_info, "Base");
- ext_version = g_match_info_fetch_named (match_info, "Ext");
- production_version = g_match_info_fetch_named (match_info, "Prod");
-
- if (base_version && !ext_version && !production_version)
+ if (base_version)
version = g_strdup (base_version);
- else if (base_version && ext_version && !production_version)
- version = g_strdup_printf("%s%s", base_version, ext_version);
- else if (base_version && !ext_version && production_version)
- version = g_strdup_printf("%s%s", base_version, production_version);
- else if (base_version && ext_version && production_version)
- version = g_strdup_printf("%s%s%s", base_version, ext_version, production_version);
return version;
}