pristine-tar: Escape '+' in match regexp
authorGuido Günther <agx@sigxcpu.org>
Fri, 17 Apr 2020 09:10:23 +0000 (11:10 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 17 Apr 2020 09:45:48 +0000 (11:45 +0200)
When looking for matching file name we need to exscape the valid '+' but
need to do it late since it must not be escaped for git-grep.

Closes: #956103
gbp/pkg/pristinetar.py

index e853407616f66e9e579284e141aaf5a316e8c464..d1a61e40ce20a4ed3c2862458435f33258a66892 100644 (file)
@@ -68,7 +68,9 @@ class PristineTar(Command):
     def _commit_contains_file(self, commit, regexp):
         """Does the given commit contain a file with the given regex"""
         files = self.repo.get_commit_info(commit)['files']
-        cregex = re.compile(regexp)
+        # CPython wants '+' (which is valid in source package names)
+        # escaped but git-grep doesn't so we do it that late:
+        cregex = re.compile(regexp.replace('+', '\\+'))
         for _, v in files.items():
             for f in v:
                 if cregex.match(f.decode()):