diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-09-04 10:44:56 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-10-07 10:34:09 +0200 |
commit | 2d8361e1cd005b30ded7f8e1b3e26543b29dfd56 (patch) | |
tree | b32cd8533e23602605fae99c48ba90d7ca97e977 | |
parent | c00c6181fb0e82aa0524e36b783e528f14650de2 (diff) |
libqmi-glib,utils: allow TAB characters as printable in strings
So that instead of this:
TLV:
type = "Model" (0x01)
length = 8
value = 45:4D:31:32:2D:41:57:09
translated = EΞE_S%P+Ç
We get this:
TLV:
type = "Model" (0x01)
length = 8
value = 45:4D:31:32:2D:41:57:09
translated = EM12-AW
(cherry picked from commit cbf0a3aa21a31f7ea24ff1fb391f50670ab6ae51)
-rw-r--r-- | src/libqmi-glib/qmi-utils.c | 6 | ||||
-rw-r--r-- | src/libqmi-glib/test/test-message.c | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/libqmi-glib/qmi-utils.c b/src/libqmi-glib/qmi-utils.c index 7fa4832..f7d186c 100644 --- a/src/libqmi-glib/qmi-utils.c +++ b/src/libqmi-glib/qmi-utils.c @@ -151,8 +151,10 @@ __qmi_string_utf8_validate_printable (const guint8 *utf8, /* Explicitly allow CR and LF even if they're control characters, given * that NMEA traces reported via QMI LOC indications seem to have these - * suffixed. */ - if (*p == '\r' || *p == '\n') + * suffixed. + * Also, explicitly allow TAB as some manufacturers seem to include it + * e.g. in model info strings. */ + if (*p == '\r' || *p == '\n' || *p == '\t') continue; unichar = g_utf8_get_char (p); diff --git a/src/libqmi-glib/test/test-message.c b/src/libqmi-glib/test/test-message.c index 7fbfbec..885be34 100644 --- a/src/libqmi-glib/test/test-message.c +++ b/src/libqmi-glib/test/test-message.c @@ -279,6 +279,23 @@ test_message_parse_string_with_trailing_nul (void) #endif +#if defined HAVE_QMI_MESSAGE_DMS_GET_MODEL + +static void +test_message_parse_string_with_trailing_tab (void) +{ + /* Quectel EM12-AW model strint has a trailing TAB character (ASCII 0x09) */ + const guint8 buffer[] = { + 0x01, 0x1E, 0x00, 0x80, 0x02, 0x05, 0x02, 0x01, 0x00, 0x22, 0x00, 0x12, + 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x45, + 0x4D, 0x31, 0x32, 0x2D, 0x41, 0x57, 0x09 + }; + + test_message_printable_common (buffer, sizeof (buffer), QMI_MESSAGE_VENDOR_GENERIC, "EM12-AW"); +} + +#endif + /*****************************************************************************/ static void @@ -1580,6 +1597,9 @@ int main (int argc, char **argv) #if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_CURRENT_FIRMWARE g_test_add_func ("/libqmi-glib/message/parse/string-with-trailing-nul", test_message_parse_string_with_trailing_nul); #endif +#if defined HAVE_QMI_MESSAGE_DMS_GET_MODEL + g_test_add_func ("/libqmi-glib/message/parse/string-with-trailing-tab", test_message_parse_string_with_trailing_tab); +#endif g_test_add_func ("/libqmi-glib/message/new/request", test_message_new_request); g_test_add_func ("/libqmi-glib/message/new/request-from-data", test_message_new_request_from_data); |