From d79e52be22f5f95393598a38dd027a083a25c23c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 14 Nov 2023 23:31:45 +0100 Subject: [PATCH] a11y atspi: Ignore malformed text attr instead of crashing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the attribute does not follow the required "name:value" syntax, ignore it, rather than crashing if it doesn't contain any colon. Same issue as spotted by Jan Arve Sæther during the review of a QTBUG-118106 related change that would have introduced the same issue in UIA code. Pick-to: 6.5 Change-Id: Id391502ed7aec7f09ef2826a456f2e4737af045e Reviewed-by: Jan Arve Sæther (cherry picked from commit b0bcf475694114bf503167bd11f14647880cd6b6) Reviewed-by: Qt Cherry-pick Bot --- src/gui/accessible/linux/atspiadaptor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/accessible/linux/atspiadaptor.cpp b/src/gui/accessible/linux/atspiadaptor.cpp index cb142a1c30f..5be7ec81768 100644 --- a/src/gui/accessible/linux/atspiadaptor.cpp +++ b/src/gui/accessible/linux/atspiadaptor.cpp @@ -2261,11 +2261,13 @@ QVariantList AtSpiAdaptor::getAttributes(QAccessibleInterface *interface, int of QString joined = interface->textInterface()->attributes(offset, &startOffset, &endOffset); const QStringList attributes = joined.split(u';', Qt::SkipEmptyParts, Qt::CaseSensitive); for (const QString &attr : attributes) { - QStringList items; - items = attr.split(u':', Qt::SkipEmptyParts, Qt::CaseSensitive); - AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]); - if (!attribute.isNull()) - set[attribute.name] = attribute.value; + QStringList items = attr.split(u':', Qt::SkipEmptyParts, Qt::CaseSensitive); + if (items.count() == 2) + { + AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]); + if (!attribute.isNull()) + set[attribute.name] = attribute.value; + } } QVariantList list;