Revert readEntryList() to use QRegExp::Wildcard
ClosedPublic

Authored by ahmadsamir on Jan 17 2020, 6:29 PM.

Details

Summary

The issue with QRegularExpression::wildcardToRegularExpression() is
that it's more strict in its interpretation of a wildcard, i.e. it
makes it correctly work with file globbing patterns, meaning it would
return this pattern "\\A(?:[^/]*)\\z" when called with "*", it excludes
"/" which is a forbidden character in a filename, and it anchors the pattern
(which is what users of QRegExp did by using QRegExp::exactMatch()).
readEntryList() uses the regex to match against entries of the form:
WEBSITE / USERNAME, which includes a "/".

Test Plan
  • Install falkon (and falkon-kde for kwallet integration, or whatever your distro calls it) and log in to a website with a user name and a password and select to remember it when asked to.
  • Restart falkon and see if the login data is shown

with this patch it should show the login data.

Diff Detail

Repository
R311 KWallet
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir created this revision.Jan 17 2020, 6:29 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 17 2020, 6:29 PM
ahmadsamir requested review of this revision.Jan 17 2020, 6:29 PM

Another way to fix the issue, would be to pass an empty QString as the first argument to readEntryList(), in which case readEntryList() returns all the entries, and to change the behaviour of readEntryList to use a full-fledged regex pattern to use instead of supporting wildcards.

ahmadsamir updated this revision to Diff 73786.Jan 17 2020, 6:34 PM
ahmadsamir edited the summary of this revision. (Show Details)
ahmadsamir edited the test plan for this revision. (Show Details)

Tweak commit message and test plan

See D26205 for details.

ahmadsamir updated this revision to Diff 73808.Jan 18 2020, 5:09 AM
ahmadsamir edited the summary of this revision. (Show Details)

Tweak commit message

dfaure accepted this revision.Jan 18 2020, 10:32 AM

Any longer terms plan for porting away from QRegExp then?

Or is it arguably a bug in QRegularExpression that is assumes globbing is only used for files?

This revision is now accepted and ready to land.Jan 18 2020, 10:32 AM

Any longer terms plan for porting away from QRegExp then?

Or is it arguably a bug in QRegularExpression that is assumes globbing is only used for files?

Qt upstream think that QRegularExpression is behaving correclty[1]; wildcard matching is used for file globbing patterns, so they make wildcardToRegularExpression return an anchored pattern, and exclude "/", which is again correct. Even QRegExp docs says the same:

QRegExp::Wildcard This provides a simple pattern matching syntax similar to that used by shells (command interpreters) for "file globbing". See QRegExp wildcard matching.

That it worked to match "all" entries in a KWallet "folder" was accidental. Also looking at the usage of readEntryList() in Falkon, technically it wants all the entries returned to list them in a configuration widget, i.e. "url | username | password".

A long term plan, well, I had a suggestion in my first comment here, basically ditch wildcard matching in readEntryList() and use a full-fledged regex instead, and using e.g. ".*" to get all entries, or checking for an empty QString() param and treat it as "I want all the entries listed".

[1] https://bugreports.qt.io/browse/QTBUG-81396

This revision was automatically updated to reflect the committed changes.