make zsh completion work again

This commit is contained in:
Kamil Dudka 2019-02-11 13:22:07 +01:00
parent 58646f29cc
commit 77901fea1d
2 changed files with 84 additions and 1 deletions

View File

@ -0,0 +1,76 @@
From 082034e2334b2d0795b2b324ff3e0635bb7d2b86 Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <alessandro@ghedini.me>
Date: Tue, 5 Feb 2019 20:44:14 +0000
Subject: [PATCH 1/2] zsh.pl: update regex to better match curl -h output
The current regex fails to match '<...>' arguments properly (e.g. those
with spaces in them), which causes an completion script with wrong
descriptions for some options.
The problem can be reproduced as follows:
% curl --reso<TAB>
Upstream-commit: dbd32f3241b297b96ee11a51da1a661f528ca026
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
scripts/zsh.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/zsh.pl b/scripts/zsh.pl
index 1257190..941b322 100755
--- a/scripts/zsh.pl
+++ b/scripts/zsh.pl
@@ -7,7 +7,7 @@ use warnings;
my $curl = $ARGV[0] || 'curl';
-my $regex = '\s+(?:(-[^\s]+),\s)?(--[^\s]+)\s([^\s.]+)?\s+(.*)';
+my $regex = '\s+(?:(-[^\s]+),\s)?(--[^\s]+)\s*(\<.+?\>)?\s+(.*)';
my @opts = parse_main_opts('--help', $regex);
my $opts_str;
--
2.17.2
From 45abc785e101346f19599aa5f9fa1617e525ec4d Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <alessandro@ghedini.me>
Date: Tue, 5 Feb 2019 21:06:26 +0000
Subject: [PATCH 2/2] zsh.pl: escape ':' character
':' is interpreted as separator by zsh, so if used as part of the argument
or option's description it needs to be escaped.
The problem can be reproduced as follows:
% curl -E <TAB>
Bug: https://bugs.debian.org/921452
Upstream-commit: b3cc8017b7364f588365be2b2629c49c142efdb7
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
scripts/zsh.pl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/zsh.pl b/scripts/zsh.pl
index 941b322..0f9cbec 100755
--- a/scripts/zsh.pl
+++ b/scripts/zsh.pl
@@ -45,9 +45,12 @@ sub parse_main_opts {
my $option = '';
+ $arg =~ s/\:/\\\:/g if defined $arg;
+
$desc =~ s/'/'\\''/g if defined $desc;
$desc =~ s/\[/\\\[/g if defined $desc;
$desc =~ s/\]/\\\]/g if defined $desc;
+ $desc =~ s/\:/\\\:/g if defined $desc;
$option .= '{' . trim($short) . ',' if defined $short;
$option .= trim($long) if defined $long;
--
2.17.2

View File

@ -1,7 +1,7 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 7.59.0
Release: 9%{?dist}
Release: 10%{?dist}
License: MIT
Source: https://curl.haxx.se/download/%{name}-%{version}.tar.xz
@ -43,6 +43,9 @@ Patch11: 0011-curl-7.59.0-CVE-2018-16840.patch
# SASL password overflow via integer overflow (CVE-2018-16839)
Patch12: 0012-curl-7.59.0-CVE-2018-16839.patch
# make zsh completion work again
Patch13: 0013-curl-7.61.1-zsh-completion.patch
# patch making libcurl multilib ready
Patch101: 0101-curl-7.32.0-multilib.patch
@ -206,6 +209,7 @@ git init
git apply %{PATCH10}
%patch11 -p1
%patch12 -p1
%patch13 -p1
# Fedora patches
%patch101 -p1
@ -352,6 +356,9 @@ rm -f ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la
%{_libdir}/libcurl.so.4.[0-9].[0-9].minimal
%changelog
* Mon Feb 11 2019 Kamil Dudka <kdudka@redhat.com> - 7.61.1-10
- make zsh completion work again
* Thu Nov 15 2018 Kamil Dudka <kdudka@redhat.com> - 7.59.0-9
- make the patch for CVE-2018-16842 apply properly (CVE-2018-16842)