From 33b3aab641f6f71f33fd87f1e1b41ea2e74f48e3 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sun, 1 Oct 2017 14:36:40 +0200 Subject: [PATCH] Validate Appdata also when appstream-util is unavailable When the dependency isn't installed, we can at least still validate whether the input is valid XML or not. As we're not printing any validation results anyway this is good enough. --- AppDataCheck.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) Index: rpmlint-rpmlint-1.10/AppDataCheck.py =================================================================== --- rpmlint-rpmlint-1.10.orig/AppDataCheck.py +++ rpmlint-rpmlint-1.10/AppDataCheck.py @@ -10,6 +10,7 @@ import AbstractCheck import Config from Filter import addDetails, printError from Pkg import getstatusoutput +import xml.etree.ElementTree as ET STANDARD_BIN_DIRS = ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'] DEFAULT_APPDATA_CHECKER = ('appstream-util', 'validate-relax') @@ -28,12 +29,18 @@ class AppDataCheck(AbstractCheck.Abstrac def check_file(self, pkg, filename): root = pkg.dirName() f = root + filename + validation_failed = False try: st = getstatusoutput(appdata_checker + (f,)) + # Return code nonzero? + validation_failed = (st[0] != 0) except OSError: - # ignore if the checker is not installed - return - if st[0]: + # checker is not installed, do a validation manually + try: + ET.parse(pkg.dirName() + filename) + except ET.ParseError: + validation_failed = True + if validation_failed: printError(pkg, 'invalid-appdata-file', filename)