Blame SOURCES/BZ-1337544-spectool-url-ignore-query.patch

42e767
commit 26a8abc746fba9c0b32eb899b96c92841a37855a
42e767
Author: Michal Domonkos <mdomonko@redhat.com>
42e767
Date:   Thu Mar 26 17:00:46 2020 +0100
42e767
42e767
    spectool: ignore query string in URL. BZ 1337544
42e767
    
42e767
    When constructing the target filename from the given Source or Patch URL
42e767
    (sub retrieve), do not include the query string (if present).
42e767
    
42e767
    Example:
42e767
    * Before: http://some.url/foo.tgz?arg=123 => ./foo.tgz?arg=123
42e767
    * After:  http://some.url/foo.tgz?arg=123 => ./foo.tgz
42e767
    
42e767
    Regex explanation:
42e767
    * 1st group: ([^\/]+?)
42e767
        * Lazily matches one or more characters that are not a forward slash
42e767
    * 2nd group: (?:\?.*)?$
42e767
        * Matches a query string (if any) starting with a question mark,
42e767
          followed by zero or more characters until the end of string,
42e767
          without creating a capturing group (the leading ?:)
42e767
42e767
diff --git a/spectool.in b/spectool.in
42e767
index 6f7499c..0ebf401 100644
42e767
--- a/spectool.in
42e767
+++ b/spectool.in
42e767
@@ -198,7 +198,7 @@ sub retrievable {
42e767
 sub retrieve {
42e767
 	my ($where, $url) = @_;
42e767
 	if (retrievable ($url)) {
42e767
-		my $path = File::Spec->catfile($where, $url =~ m|([^/]+)$|);
42e767
+		my $path = File::Spec->catfile($where, $url =~ m|([^\/]+?)(?:\?.*)?$|);
42e767
 		print "Getting $url to $path\n";
42e767
 		if (-e $path) {
42e767
 			if ($force) {