PackageKit / PackageKit

A D-BUS abstraction layer that allows the user to manage packages in a secure way using a cross-distro, cross-architecture API.
https://www.freedesktop.org/software/PackageKit/
GNU General Public License v2.0
260 stars 164 forks source link

apt: Fix 'search-file' regexp as per BRE pattern (which is the default) #649

Closed sidt4 closed 1 year ago

sidt4 commented 1 year ago

We should either set the 'REG_EXTENDED' flag (Extended Regular Expressions) to regcomp() and use the "|" regex pattern, or use the "\\|" regex pattern, as per the BRE (Basic Regular Expressions), which is the default when 'REG_EXTENDED' flag is not set.

From 'man grep':

Basic vs Extended Regular Expressions:

In basic regular expressions the meta‐characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, +, {, |, (, and ).

ximion commented 1 year ago

Good catch! - This whole code is really ugly in general though and would need a lot of refactoring due to https://lintian.debian.org/tags/uses-dpkg-database-directly But for now, at least this patch makes the code a bit less buggy. Thank you for the patch!

sidt4 commented 1 year ago

https://lintian.debian.org/tags/uses-dpkg-database-directly

I guess we can access all functionality through libapt-pkg interface, which is the gateway to apt database.

ximion commented 1 year ago

I guess we can access all functionality through libapt-pkg interface, which is the gateway to apt database.

Not in the past, but the API surface has been expanded greatly in the past decade, so maybe API for this functionality now exists.

sidt4 commented 1 year ago

Should this be patched in v1.2.6 in debian downstream ?

I see that you are the maintainer for https://tracker.debian.org/pkg/packagekit

ximion commented 1 year ago

I'll make a new PackageKit release soon, so no need for that (in unstable/testing, at least).

sidt4 commented 1 year ago

I was more concerned about the bookworm not testing / unstable which doesn't impact normal users. Once the fix for https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2254 lands, I'd get it backported to gnome-software-43.5 in bookworm, which would require this patch.