From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add shell-quasiquote. Date: Sat, 17 Oct 2015 20:23:17 +0200 Message-ID: <87twppuzfu.fsf@T420.taylan> References: <87si59wj42.fsf@T420.taylan> <83eggt4esi.fsf@gnu.org> <87fv19wh7b.fsf@T420.taylan> <83bnbx4d7e.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1445106211 20652 80.91.229.3 (17 Oct 2015 18:23:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2015 18:23:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 17 20:23:30 2015 Return-path: Envelope-to: ged-emacs-devel@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 1ZnW8b-0006CY-VF for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 20:23:26 +0200 Original-Received: from localhost ([::1]:59403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnW8b-0005JD-0H for ged-emacs-devel@m.gmane.org; Sat, 17 Oct 2015 14:23:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnW8W-0005IZ-NT for emacs-devel@gnu.org; Sat, 17 Oct 2015 14:23:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnW8V-00077l-Pa for emacs-devel@gnu.org; Sat, 17 Oct 2015 14:23:20 -0400 Original-Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:36407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnW8V-00077N-IF; Sat, 17 Oct 2015 14:23:19 -0400 Original-Received: by wicfx6 with SMTP id fx6so1403067wic.1; Sat, 17 Oct 2015 11:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=TTCluSSTOZ0d5CnnCHcgzxn+JeIllaQS9UEOT6HMM4E=; b=Ged2+Ii736DSV5BlvClHVQb67Lgq72Ly0NY4e13pgsAGtfRUmN3pVskpdcj7sGMrxw qkzb7klYTkB9l5WILGN6d/24w22cvLGG5UdpqsOWJCp0Yi/UP6KxSi8pmdJiEXgeYxi8 7pKCo3vtuIucJMveII4ffiFx7zu9UpcTfiX0fGePUmHgNh6eWVM75py8hziq8/IWmDr0 aRocjZWiKh+TBJFyjqB2IYQm9RNuEeATObQt/N89emxl3eWLVtyiNHBBWMNBmbQoSUCb oFesX/M02z7RSZg+v0XK96D21/c6WEFR2l2hoSynFJWwhvjwn+4YXrDDrfMkpRLYnMzN 70xQ== X-Received: by 10.180.106.37 with SMTP id gr5mr11555273wib.86.1445106198965; Sat, 17 Oct 2015 11:23:18 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id qq4sm29586663wjc.14.2015.10.17.11.23.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 11:23:18 -0700 (PDT) In-Reply-To: <83bnbx4d7e.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 17 Oct 2015 20:28:05 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:191869 Archived-At: Eli Zaretskii writes: >> From: taylanbayirli@gmail.com (Taylan Ulrich Bay=C4=B1rl=C4=B1/Kammer) >> Cc: emacs-devel@gnu.org >> Date: Sat, 17 Oct 2015 19:14:16 +0200 >>=20 >> Eli Zaretskii writes: >>=20 >> >> +;;; Like `shell-quote-argument', but much simpler in implementation. >> >> +(defun shqq--quote-string (string) >> >> + (concat "'" (replace-regexp-in-string "'" "'\\\\''" string) "'")) >> > >> > It might be simpler, but it's wrong, because the result is only >> > correct for Posix shells. >> > >> > Please do use shell-quote-argument instead. >>=20 >> Hmm, I don't really want to take responsibility of my library being used >> with shells other than POSIX shells. (The library could make that >> clearer and error on other systems.) > > I don't think we'd like to have packages limited in that way. AFAIK, > we didn't until now, at least not consciously. Quoting RMS, coincidentally from a couple days ago: The policy is non-GNU systems are secondary, and lower priority than the GNU system, but we are glad to include support for them in GNU packages if users contribute the necessary code -- provided that code isn't a maintenance problem for us. The maintenainers of any particular package are the ones who judge whether that code is a maintenance problem, since they are the ones it would be a problem for. (That mentality made sense to me even before I learned it's GNU policy.) I generally don't want to take responsibility of my code being used on non-GNU/non-POSIX systems, but if I can share the responsibility then that's fine. > And it really isn't a big deal. Emacs already has all the > infrastructure for portable handling of shell commands. > >> How much can I rely on shell-quote-argument? > > You can rely on it. Emacs uses it in umpteen important places. > >> Can one fully rely on it being safe against code injection? > > I don't think I understand what code injection you had in mind. > Please elaborate. (let ((file-list (read where-ever))) (shqq (cp -- ,@file-list some-place))) That code is *guaranteed* to either copy the files in file-list to some-place, or error, so long as the argument quoting by shqq works well. If it has a bug, then malicious input from where-ever may be able to execute arbitrary shell commands. Is shell-quote-argument safe against such a thing? My shqq-quote-string isn't exactly formally proven to be safe either, but its implementation is so simple it's fairly obvious that it doesn't contain bugs. Taylan