From f56cd6971caff38752def957487ba6a057aab80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= Date: Wed, 16 Dec 2020 16:34:06 +0100 Subject: [PATCH] util: Improve regexes for parsing problem data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replace ranges with PCRE escapes, e.g. `a-zA-Z` → `\w`. * Fix package name (NEV) parser to correctly handle epoch numbers. The epoch was previously assumed to be a prefix of the whole name (in ENV form), e.g. `1:findutils-4.7.0-4.fc33`. In order to be consistent with abrt, DNF and RPM, we switch to NEV form, that is `findutils-1:4.7.0-4.fc33`. --- src/retrace/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/retrace/util.py b/src/retrace/util.py index a4fa658e..971f9fb6 100644 --- a/src/retrace/util.py +++ b/src/retrace/util.py @@ -19,15 +19,15 @@ DF_OUTPUT_PARSER = re.compile(r"^([^ ^\t]*)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+%)[ \t]+(.*)$") # architecture (i386, x86_64, armv7hl, mips4kec) -INPUT_ARCH_PARSER = re.compile(r"^[a-zA-Z0-9_]+$") +INPUT_ARCH_PARSER = re.compile(r"^[\w\d_]+$") # characters, numbers, dash (utf-8, iso-8859-2 etc.) -INPUT_CHARSET_PARSER = re.compile(r"^([a-zA-Z0-9\-]+)(,.*)?$") +INPUT_CHARSET_PARSER = re.compile(r"^([\w\d-]+)(,.*)?$") # en_GB, sk-SK, cs, fr etc. INPUT_LANG_PARSER = re.compile(r"^([a-z]{2}([_\-][A-Z]{2})?)(,.*)?$") # characters allowed by Fedora Naming Guidelines -INPUT_PACKAGE_PARSER = re.compile(r"^([1-9][0-9]*:)?[a-zA-Z0-9\-\.\_\+\~]+$") +INPUT_PACKAGE_PARSER = re.compile(r"^[\w\d_.+-]+([1-9][0-9]*:)?[\w\d.+~-]+$") # name-version-arch (fedora-16-x86_64, rhel-6.2-i386, opensuse-12.1-x86_64) -INPUT_RELEASEID_PARSER = re.compile(r"^[a-zA-Z0-9]+\-[0-9a-zA-Z\.]+\-[a-zA-Z0-9_]+$") +INPUT_RELEASEID_PARSER = re.compile(r"^[\w\d]+-[\w\d.]+-[\w\d_]+$") UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB"] URL_PARSER = re.compile(r"^/([0-9]+)/?")