Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
util: Improve regexes for parsing problem data
Browse files Browse the repository at this point in the history
* 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`.
  • Loading branch information
mgrabovsky authored and xsuchy committed Dec 16, 2020
1 parent 9b5899f commit 84d67af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/retrace/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)/?")
Expand Down

0 comments on commit 84d67af

Please sign in to comment.