IPC: disallow unknown queries in QNativeIpcKey string form
So we can add them in the future but cause older versions of Qt to reject them if they don't know what they are. Change-Id: I512648fd617741199e67fffd1782b85935bb832a Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 18867845eb77537c4125e1da4dfcd049e303ee27) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit a5a1231d527a259d0dac9dc62e04a284fe183d51)
This commit is contained in:
parent
60d41595f6
commit
0641d4e5a7
@ -560,7 +560,7 @@ QNativeIpcKey QNativeIpcKey::fromString(const QString &text)
|
||||
Type invalidType = {};
|
||||
Type type = stringToType(u.scheme());
|
||||
if (type == invalidType || !u.isValid() || !u.userInfo().isEmpty() || !u.host().isEmpty()
|
||||
|| u.port() != -1)
|
||||
|| u.port() != -1 || u.hasQuery())
|
||||
return QNativeIpcKey(invalidType);
|
||||
|
||||
QNativeIpcKey result(QString(), type);
|
||||
@ -569,6 +569,7 @@ QNativeIpcKey QNativeIpcKey::fromString(const QString &text)
|
||||
|
||||
// decode the payload
|
||||
result.setNativeKey(u.path());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -280,12 +280,14 @@ void tst_QNativeIpcKey::fromString_data()
|
||||
<< "posix:%C4%80.%E2%80%80.%F0%90%80%80"
|
||||
<< QNativeIpcKey(u"\u0100.\u2000.\U00010000"_s, QNativeIpcKey::Type::PosixRealtime);
|
||||
|
||||
// query and fragment are ignored
|
||||
QTest::addRow("with-query") << "posix:/foo?bar" << valid;
|
||||
// fragments are ignored
|
||||
QTest::addRow("with-fragment") << "posix:/foo#bar" << valid;
|
||||
QTest::addRow("with-queryfragment") << "posix:/foo?bar#baz" << valid;
|
||||
QTest::addRow("with-fragmentquery") << "posix:/foo#bar?baz" << valid;
|
||||
|
||||
// but unknown query items are not
|
||||
QTest::addRow("with-query") << "posix:/foo?bar" << invalid;
|
||||
QTest::addRow("with-queryfragment") << "posix:/foo?bar#baz" << invalid;
|
||||
|
||||
// add some ones that won't parse well
|
||||
QTest::addRow("positive-number") << "81" << invalid;
|
||||
QTest::addRow("negative-number") << "-81" << invalid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user