summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2023-06-19 12:05:15 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-06-20 06:26:26 +0000
commit2e5dd66c77a4d432a68e2f17e1548de046123c7a (patch)
tree7bd53739ccec820bf3e1edda761c2093e18f674a
parentedd7b5de76e7bb4386e1b6b7694e1f47e4f3e922 (diff)
Accept any printable character in CAN DBC char_string
CAN DBC char_string can accept any printable character, according to standard specification. For now, only 0x20 - 0x7E were accepted, which made some possible characters, including e.g. the degree sign U+00B0 to not get correctly parsed. Fixes: QTBUG-114619 Change-Id: I51766e847110641f786ab1f5f3aed89572335d6f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de> (cherry picked from commit c7cdbe4cc4ba4b4456a4cbab4eaea2ea9b6326ed) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/serialbus/qcandbcfileparser.cpp7
-rw-r--r--tests/auto/qcandbcfileparser/data/char_string_test.dbc2
-rw-r--r--tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp2
3 files changed, 5 insertions, 6 deletions
diff --git a/src/serialbus/qcandbcfileparser.cpp b/src/serialbus/qcandbcfileparser.cpp
index 63d4f98..c32c9bb 100644
--- a/src/serialbus/qcandbcfileparser.cpp
+++ b/src/serialbus/qcandbcfileparser.cpp
@@ -306,9 +306,8 @@ static constexpr auto kMaybeSpaceRegExp = "[ ]*"_L1;
static constexpr auto kMuxIndicatorRegExp = "M|m\\d+M?"_L1;
static constexpr auto kByteOrderRegExp = "0|1"_L1;
static constexpr auto kValueTypeRegExp = "\\+|\\-"_L1;
-// The pattern matches all ASCII characters in range 0x20 - 0x7E, except
-// double-quote (") and backslash (\).
-static constexpr auto kCharStrRegExp = "((?![\\\"\\\\])[\x20-\x7e])*"_L1;
+// The pattern matches all printable characters, except double-quote (") and backslash (\).
+static constexpr auto kCharStrRegExp = "((?![\\\"\\\\])\\P{Cc})*"_L1;
void QCanDbcFileParserPrivate::reset()
{
@@ -341,7 +340,7 @@ bool QCanDbcFileParserPrivate::parseFile(const QString &fileName)
m_seenExtraData = false;
while (!f.atEnd()) {
- const QString str = QString::fromLatin1(f.readLine().trimmed());
+ const QString str = QString::fromUtf8(f.readLine().trimmed());
if (!processLine({str.constData(), str.size()})) // also sets the error properly
return false;
}
diff --git a/tests/auto/qcandbcfileparser/data/char_string_test.dbc b/tests/auto/qcandbcfileparser/data/char_string_test.dbc
index 7b2fb7e..34460b2 100644
--- a/tests/auto/qcandbcfileparser/data/char_string_test.dbc
+++ b/tests/auto/qcandbcfileparser/data/char_string_test.dbc
@@ -1,4 +1,4 @@
BO_ 1234 Test : 8 Vector__XXX
- SG_ s0 : 0|8@1+ (1,0) [0|0] " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~" Vector__XXX
+ SG_ s0 : 0|8@1+ (1,0) [0|0] " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~°" Vector__XXX
SG_ s1 : 0|8@1+ (1,0) [0|0] "double quote: "" Vector__XXX
SG_ s2 : 0|8@1+ (1,0) [0|0] "backslash: \" Vector__XXX
diff --git a/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp b/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp
index 260da11..17301cc 100644
--- a/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp
+++ b/tests/auto/qcandbcfileparser/tst_qcandbcfileparser.cpp
@@ -745,7 +745,7 @@ void tst_QCanDbcFileParser::parseFile_data()
signalDesc.setOffset(0.0);
signalDesc.setRange(0.0, 0.0);
signalDesc.setPhysicalUnit(" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "[]^_`abcdefghijklmnopqrstuvwxyz{|}~");
+ "[]^_`abcdefghijklmnopqrstuvwxyz{|}~°");
signalDesc.setReceiver("Vector__XXX");
messageDesc.addSignalDescription(signalDesc);