Fix filter parsing in flatpak FileChooser portal

Filters are usually in format (Name (*.foo *.bar)), but valid filter is
also (Name ( *.bar *.foo )), containing additional spaces. When we split
content in the brackets divided by spaces, there will be then empty
strings which we need to filter out, otherwise the result we send over
DBus is not valid.

Change-Id: Iaa265189408f47324bc9b269d534bf4c8d7d2cae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jan Grulich 2018-05-14 12:08:58 +02:00
parent c4cbb3f315
commit d55165b9c4

View File

@ -210,7 +210,7 @@ void QFlatpakFileDialog::openPortal()
QRegularExpressionMatch match = regexp.match(filter); QRegularExpressionMatch match = regexp.match(filter);
if (match.hasMatch()) { if (match.hasMatch()) {
QString userVisibleName = match.captured(1); QString userVisibleName = match.captured(1);
QStringList filterStrings = match.captured(2).split(QLatin1String(" ")); QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), QString::SkipEmptyParts);
FilterConditionList filterConditions; FilterConditionList filterConditions;
for (const QString &filterString : filterStrings) { for (const QString &filterString : filterStrings) {