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.
This commit is contained in:
Carlo Lobrano
2022-04-11 17:52:25 +02:00
parent 818b539d65
commit 0645b70aea

View File

@@ -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;
}