From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#20333: 24.3; Add warning about shell quoting to documentation of combine-and-quote-strings Date: Sun, 03 Jul 2016 10:03:55 -0400 Message-ID: <87bn2eg6no.fsf@users.sourceforge.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1467554667 3898 80.91.229.3 (3 Jul 2016 14:04:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Jul 2016 14:04:27 +0000 (UTC) Cc: 20333@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 03 16:04:16 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bJi0N-0001bB-FQ for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Jul 2016 16:04:15 +0200 Original-Received: from localhost ([::1]:42764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJi0M-0001t1-LX for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Jul 2016 10:04:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJi0F-0001rY-SK for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2016 10:04:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJi0A-0000j8-QG for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2016 10:04:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJi0A-0000j1-MY for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2016 10:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bJi0A-0000V5-CA for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2016 10:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jul 2016 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20333 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20333-submit@debbugs.gnu.org id=B20333.14675546351911 (code B ref 20333); Sun, 03 Jul 2016 14:04:02 +0000 Original-Received: (at 20333) by debbugs.gnu.org; 3 Jul 2016 14:03:55 +0000 Original-Received: from localhost ([127.0.0.1]:36005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJi03-0000Ui-0O for submit@debbugs.gnu.org; Sun, 03 Jul 2016 10:03:55 -0400 Original-Received: from mail-it0-f43.google.com ([209.85.214.43]:35548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJi01-0000UL-0V; Sun, 03 Jul 2016 10:03:53 -0400 Original-Received: by mail-it0-f43.google.com with SMTP id j185so13819853ith.0; Sun, 03 Jul 2016 07:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=jWPK6oy1ShIUjvH/+kYTIRrJcfhHjDTa/pGY0dcbxsQ=; b=fL9wWA2s0dQobkD6Rde1O3zHji2uZOO37e1piPcmxQdUMMeVm/knVWrWkpqVpykaZe dfvpolWWitTZ3q0iU9k/54UCRiXULhM+d9RAK08PP/yuRFhc2gRJwxAOsBF3y62pjNBD 65sv3Dw22hz8qGurXhinvdjRsOc/+4IZErkeKuyaHs6zxfQ+eASS8GLpPwkhcuVumuvw meURRTIKwggEgvTva52ekSn5vKA1Z+Lljh8hjbmhgWcjKyvlPmLCCiLk22flJ6mM6f25 5STO9HEGtclRp0CbLzhFHFI86Sqjr4dk7fpXvGedB599Ri+2QNa3qrLocs5npoZNkVI1 QutQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=jWPK6oy1ShIUjvH/+kYTIRrJcfhHjDTa/pGY0dcbxsQ=; b=VwwpzsiCkj8UswXSiseIHfn+sYtmDT/+jt9Q9lyzdiLrlZ2vB9oMm7sFt6fOaU6oNu KcOS2Qk4gm/Wfvlm/SEMumerRodUwyu3iCpWZwDkCooyxdGkvppmejjIPYrUTuD3nPTK Ry8gOllCbbTDKpUcR+8ivBFm3Lb6n1E2xd6OR0WAJcVlPwAX/a5QCfxwg1a5r9BanlCy alNO2viyteVh/01euhbI/CdjXrd4ZMrFvwZA93ixVHe3oL205V2UPeRqgT/yTDoO0zGz i9OeHOXPfjmcA7mz2XnYFTyp09NQplyYXMUJtgMQYAo/mj0uX8SeqUXKm1FtRWB7Oqs/ AHkg== X-Gm-Message-State: ALyK8tL0xNNLx3jwUeTvaduvkP5bupWqpk/OIXx+zKV6fIOfN6Y9RZK/wjRvDw3QqVVE3w== X-Received: by 10.36.105.210 with SMTP id e201mr5658259itc.86.1467554627528; Sun, 03 Jul 2016 07:03:47 -0700 (PDT) Original-Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id q128sm3772847iod.30.2016.07.03.07.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jul 2016 07:03:46 -0700 (PDT) In-Reply-To: (Philipp Stephani's message of "Tue, 14 Apr 2015 21:03:18 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120333 Archived-At: --=-=-= Content-Type: text/plain tags 20333 patch quit Philipp Stephani writes: > Context and more discussion: > http://lists.gnu.org/archive/html/help-gnu-emacs/2015-04/msg00179.html > > It would be great if the documentation string and the Elisp manual about > `combine-and-quote-strings' could be made a bit clearer by explicitly > stating that this function is not useful for shell quoting. How about this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Note-combine-and-quote-strings-doesn-t-shell-quot.patch Content-Description: patch >From 5a1d23231bcf3c279fd3b09654fb132513748e6c Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 3 Jul 2016 09:56:36 -0400 Subject: [PATCH v1] Note combine-and-quote-strings doesn't shell quote * doc/lispref/processes.texi (Shell Arguments): * lisp/subr.el (combine-and-quote-strings): Add a note that combine-and-quote-strings doesn't protect arguments against shell evaluation (Bug #20333). --- doc/lispref/processes.texi | 5 +++++ lisp/subr.el | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 5bd0b11..b4542f6 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -215,6 +215,11 @@ Shell Arguments string arguments to be passed to @code{call-process} or @code{start-process}, or for converting such lists of arguments into a single Lisp string to be presented in the minibuffer or echo area. +Note that if a shell is involved (e.g., if using +@code{call-process-shell-command}), arguments should still be +protected by @code{shell-quote-argument}; +@code{combine-and-quote-strings} is @emph{not} intended to protect +special characters from shell evaluation. @defun split-string-and-unquote string &optional separators This function splits @var{string} into substrings at matches for the diff --git a/lisp/subr.el b/lisp/subr.el index ed2166a..e9e19d3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3706,7 +3706,10 @@ combine-and-quote-strings "Concatenate the STRINGS, adding the SEPARATOR (default \" \"). This tries to quote the strings to avoid ambiguity such that (split-string-and-unquote (combine-and-quote-strings strs)) == strs -Only some SEPARATORs will work properly." +Only some SEPARATORs will work properly. + +Note that this is not intended to protect STRINGS from +interpretation by shells, use `shell-quote-argument' for that." (let* ((sep (or separator " ")) (re (concat "[\\\"]" "\\|" (regexp-quote sep)))) (mapconcat -- 2.8.0 --=-=-=--