Package: apt-file
Version: 2.4.0
Severity: important
Tags: patch

A known example in the archive:

  apt-file search /zynaddsubfx/examples/Synth

Expected result:

  zynaddsubfx-data: /usr/share/zynaddsubfx/examples/Synth Bells Choir Reverb.xmz
  zynaddsubfx-data: /usr/share/zynaddsubfx/examples/Synth Piano Reverb.xmz
  zynaddsubfx-data: /usr/share/zynaddsubfx/examples/Synth.xmz

Actual result:

  zynaddsubfx-data: /usr/share/zynaddsubfx/examples/Synth.xmz

The bug is due to apt-file putting an incorrect prefix to the search
term, which assumes there will be no spaces in the filename after the
search team.

This affects -x / --regexp and --substring-match based searches.
However, -F based searches are unaffected (as they will only match the
full file name).

Patch being:

diff --git a/apt-file b/apt-file
index 8a1ba59..5aba425 100755
--- a/apt-file
+++ b/apt-file
@@ -350,8 +350,8 @@ sub grep_file($) {
     }
 
     if ( ! defined $Conf->{fixed_strings} && ! defined $Conf->{is_regexp} ) {
-        $pattern  .= '[^\s]*';
-        $pattern2 .= '[^\s]*' if defined $pattern2;
+        $pattern  .= '(?:.*[^\s])?';
+        $pattern2 .= '(?:.*[^\s])?' if defined $pattern2;
     }
 
     $pattern = "$pattern|$pattern2" if defined $pattern2;

Reply via email to