#109 Escape source name before regex'ing.
Merged 5 years ago by pingou. Opened 5 years ago by qulogic.
qulogic/mdapi re-escape  into  master

file modified
+2 -1
@@ -91,10 +91,11 @@ 

                      pkg = [Packages(*item) for item in pkgc]

                      break

              elif srcname:

-                 pattern = re.compile(f"{srcname}-[0-9]")

                  async with db.execute(GET_PACKAGE_BY_SRC, (srcname+'-%',)) as cursor:

                      pkgc = await cursor.fetchall()

                  if pkgc:

+                     srcname = re.escape(srcname)

+                     pattern = re.compile(f"{srcname}-[0-9]")

                      for pkg_item in pkgc:

                          if pattern.match(pkg_item[3]):

                              pkg = Packages(*pkg_item)

Otherwise, looking for /rawhide/srcpkg/gcc-c++ would cause a traceback and return a 500, instead of a 404.

Also, only compile regex if we found some packages.

Good catch, thanks! :)

Pull-Request has been merged by pingou

5 years ago
Metadata