D7170: Fix errorneous whitespace handling in Desktop Entry parsing from DesktopFileParser

Michael Pyne noreply at phabricator.kde.org
Mon Aug 7 02:03:03 UTC 2017


mpyne created this revision.
Restricted Application added a project: Frameworks.

REVISION SUMMARY
  As reported in bug 310674, the Desktop Entry spec says that whitespace surrounding the = sign that separates the key and value in .desktop files should be ignored when interpreting the key and value portions.
  
  That is, all four of these lines should be equivalent:
  
    Type=Application
    Type =Application
    Type= Application
    Type = Application
  
  DesktopFileParser handles this for most key/value entries already (e.g. at src/lib/plugin/desktopfileparser.cpp:266), but there is a specific function to handle reading `Type=` entries from desktop files which doesn't handle spaces (and even has a TODO asking whether it should).
  
  This patch implements the spec here by using `QRegularExpression` to match the part of the string after `=\s*`.

TEST PLAN
  Existing autotests have been modified to include spaces around some of the `Type=` entries, and the updated autotests now pass.

REPOSITORY
  R244 KCoreAddons

REVISION DETAIL
  https://phabricator.kde.org/D7170

AFFECTED FILES
  autotests/desktoptojsontest.cpp
  src/lib/plugin/desktopfileparser.cpp

To: mpyne, #frameworks, arichardson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170807/649f617b/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list