From 6faa80d27465705b8f1191da4eb324f2f0e71e7ddc1b21f0d9ee5125b86b70df Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Mon, 16 Oct 2017 09:00:07 +0000 Subject: [PATCH] - refresh 0001-Improve-XDG-Menu-checks-stability.patch (bsc#1063371) OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=534 --- 0001-Improve-XDG-Menu-checks-stability.patch | 38 +++++++++++++------- rpmlint.changes | 5 +++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/0001-Improve-XDG-Menu-checks-stability.patch b/0001-Improve-XDG-Menu-checks-stability.patch index b1305cd..3a71517 100644 --- a/0001-Improve-XDG-Menu-checks-stability.patch +++ b/0001-Improve-XDG-Menu-checks-stability.patch @@ -1,4 +1,4 @@ -From 3df5fd9507215cf70a1147ea631cf061475c7b34 Mon Sep 17 00:00:00 2001 +From e6594808fdf6c1fcb4175c523582ab7c358839f0 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 29 Sep 2017 09:12:33 +0200 Subject: [PATCH] Improve XDG Menu checks stability @@ -7,8 +7,12 @@ Running RawConfigParser on untrusted input can cause a lot of exceptions. Handle them gracefully and raise appropriate rpmlint errors. Also separate the code a little and cleaning it up. --- - MenuXDGCheck.py | 76 ++++++++++++++++++++++++++++++++++++++++----------------- - 1 file changed, 53 insertions(+), 23 deletions(-) + MenuXDGCheck.py | 84 ++++++++++++++++++++++++++---------- + test/binary/menuxdg1-0-0.noarch.rpm | Bin 0 -> 6555 bytes + test/test_menuxdg.py | 17 ++++++++ + 3 files changed, 78 insertions(+), 23 deletions(-) + create mode 100644 test/binary/menuxdg1-0-0.noarch.rpm + create mode 100644 test/test_menuxdg.py Index: rpmlint-rpmlint-1.10/MenuXDGCheck.py =================================================================== @@ -33,28 +37,36 @@ Index: rpmlint-rpmlint-1.10/MenuXDGCheck.py class MenuXDGCheck(AbstractCheck.AbstractFilesCheck): -@@ -27,6 +27,43 @@ class MenuXDGCheck(AbstractCheck.Abstrac +@@ -27,6 +27,51 @@ class MenuXDGCheck(AbstractCheck.Abstrac AbstractCheck.AbstractFilesCheck.__init__( self, "MenuXDGCheck", r"(?:/usr/share|/etc/opt/.*/share|/opt/.*)/applications/.*\.desktop$") + def parse_desktop_file(self, pkg, root, f, filename): + cfp = cfgparser.RawConfigParser() + try: -+ cfp.read(f) ++ with open(f) as inputf: ++ cfp.readfp(inputf, filename) + except cfgparser.DuplicateSectionError as e: + printError( + pkg, 'desktopfile-duplicate-section', filename, + '[%s]' % e.section) -+ except cfgparser.DuplicateOptionError as e: -+ printError( -+ pkg, 'desktopfile-duplicate-option', filename, -+ '[%s]/%s' % (e.section, e.option)) + except cfgparser.MissingSectionHeaderError: + printError( + pkg, 'desktopfile-missing-header', filename) -+ except (cfgparser.ParsingError, UnicodeDecodeError) as e: ++ except cfgparser.Error as e: ++ # Only in Python >= 3.2 ++ if (hasattr(cfgparser, 'DuplicateOptionError') and ++ isinstance(e, cfgparser.DuplicateOptionError)): ++ printError( ++ pkg, 'desktopfile-duplicate-option', filename, ++ '[%s]/%s' % (e.section, e.option)) ++ else: ++ printWarning( ++ pkg, 'invalid-desktopfile', filename, ++ e.message.partition(':')[0]) ++ except UnicodeDecodeError as e: + printWarning( -+ pkg, 'invalid-desktopfile', filename) ++ pkg, 'invalid-desktopfile', filename, 'No valid Unicode') + else: + binary = None + if cfp.has_option('Desktop Entry', 'Exec'): @@ -77,7 +89,7 @@ Index: rpmlint-rpmlint-1.10/MenuXDGCheck.py def check_file(self, pkg, filename): root = pkg.dirName() f = root + filename -@@ -43,25 +80,7 @@ class MenuXDGCheck(AbstractCheck.Abstrac +@@ -43,25 +88,7 @@ class MenuXDGCheck(AbstractCheck.Abstrac if not is_utf8(f): printError(pkg, 'non-utf8-desktopfile', filename) @@ -104,7 +116,7 @@ Index: rpmlint-rpmlint-1.10/MenuXDGCheck.py check = MenuXDGCheck() -@@ -76,4 +95,15 @@ addDetails( +@@ -76,4 +103,15 @@ addDetails( 'desktopfile-without-binary', '''the .desktop file is for a file not present in the package. You should check the requires or see if this is not a error''', diff --git a/rpmlint.changes b/rpmlint.changes index b892a27..7576d7c 100644 --- a/rpmlint.changes +++ b/rpmlint.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Oct 16 08:58:07 UTC 2017 - dmueller@suse.com + +- refresh 0001-Improve-XDG-Menu-checks-stability.patch (bsc#1063371) + ------------------------------------------------------------------- Wed Oct 11 08:03:12 UTC 2017 - opensuse-packaging@opensuse.org