Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 59743) by debbugs.gnu.org; 2 Dec 2022 02:16:37 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 01 21:16:37 2022 Received: from localhost ([127.0.0.1]:43323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1p0vbR-0004hk-Kv for submit <at> debbugs.gnu.org; Thu, 01 Dec 2022 21:16:37 -0500 Received: from mail-pl1-f180.google.com ([209.85.214.180]:35504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <jporterbugs@HIDDEN>) id 1p0vbM-0004hZ-43 for 59743 <at> debbugs.gnu.org; Thu, 01 Dec 2022 21:16:36 -0500 Received: by mail-pl1-f180.google.com with SMTP id y4so3407591plb.2 for <59743 <at> debbugs.gnu.org>; Thu, 01 Dec 2022 18:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=jKjOWzC7vkYKeJWefiLJZw4Qxr9G14SvkviJqCZol6w=; b=WSe55rue6pFpDWUVjui8qM071WsE889em2B+t3Tupbe0+ssvlRLiWZB+gufU8TRwOO Xj43NRR3ybcdXGiXRWoPUzeP6HLRY6hgia/Sc2JpC7u0R3D+2cspz3t+kLwrXJ3ozJEQ T8R+aztIK6cPxhnM+TCcYRWrFtq1u7iAeqZEH0Co0EDdX3u7f/mzWgHbFuWkcnowtSGh 4LbV0XdEVdWDMUEAK5YaiGv8AyD1+RwZLEA/NA2CggsyKoseV7Wo+3X7h3wAScaxedxN vG8YyjGGnG7bdGfoEFSdgU0lqRxgeJ2jt1ULbww2wtZbmLmQ+36t2uYv0r3me2J0+GzE O0kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jKjOWzC7vkYKeJWefiLJZw4Qxr9G14SvkviJqCZol6w=; b=wG6zYRjL4wud3IGwYIA6G+Dpcbc/aeP2VChwyyRjvv6TloCFGdLNU+3NnDxeWvgiLJ H7027RN74w9kFVLFugpywmCpsQ6+IBmA39HdEEYVH8B/tFgGcXinXSD86od75v3qMQZw D4YPoo7bO1Jl0KRj4wKJMpYoHzLGqPv2KE1t6WHuxozgvE+fffigvMjBz8mF08ASgcKb BvFqIQq6Vq+KDTDWTBR/L1l6RQAAaRAsq1SrjQTYW/fSbTpI43RvMXT/KyuoubkIwIr9 fxu2LfbhEZkzKcIFodk/e9hkHQTkYq2sVKTamdEW+5gQSNVXKhU18HBWiR7PSLSIfAIk +dVA== X-Gm-Message-State: ANoB5plbc3sybWwM0o8qtBHyyLpjJJqMCcwYva9H2B7qsbaVxs8lHPQv kvRG6PRk0E81ePaHfzdjeK0= X-Google-Smtp-Source: AA0mqf4YRxHNoIekFIKvpcXyN3Jnwc32h9OnUoBmb3vn9PdiPaVW/DnYprFH/SNrGpseb9ntHQUNaQ== X-Received: by 2002:a17:902:7089:b0:187:4ace:e20c with SMTP id z9-20020a170902708900b001874acee20cmr51211438plk.75.1669947386278; Thu, 01 Dec 2022 18:16:26 -0800 (PST) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id s9-20020a170902b18900b0017f8094a52asm4310809plr.29.2022.12.01.18.16.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 18:16:25 -0800 (PST) Message-ID: <29ab47d9-507a-08ae-9b40-0662168eb9cb@HIDDEN> Date: Thu, 1 Dec 2022 18:16:25 -0800 MIME-Version: 1.0 Subject: Re: bug#59743: Implement `command-line-args-left' for emacsclient --eval expressions Content-Language: en-US To: Max Nikulin <manikulin@HIDDEN>, 59743 <at> debbugs.gnu.org References: <438a7286-ee4c-74a1-c24b-d788a6507ad6@HIDDEN> From: Jim Porter <jporterbugs@HIDDEN> In-Reply-To: <438a7286-ee4c-74a1-c24b-d788a6507ad6@HIDDEN> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59743 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On 12/1/2022 7:06 AM, Max Nikulin wrote: > I propose to expand protocol of communication between emacsclient and > server to allow passing of arbitrary arguments for --eval expression > that are not treated as files. The goal is to pass strings to evaluated > expressions in a safe way without necessity of escaping double quotes > and backslashes. > > I suggest to add e,g, --args option of emacsclient that transfers > everything after it (including arguments starting with dash) to server > and causes let-binding the list to command-line-args-left (or another > variable) before execution of preceding --eval options. I believe this is a duplicate of bug#57752, where I and several others previously discussed a few options to solve this.
bug-gnu-emacs@HIDDEN
:bug#59743
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 1 Dec 2022 15:06:16 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 01 10:06:16 2022 Received: from localhost ([127.0.0.1]:40187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1p0l8h-0008Ub-JL for submit <at> debbugs.gnu.org; Thu, 01 Dec 2022 10:06:16 -0500 Received: from lists.gnu.org ([209.51.188.17]:60954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <manikulin@HIDDEN>) id 1p0l8f-0008UV-5F for submit <at> debbugs.gnu.org; Thu, 01 Dec 2022 10:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <manikulin@HIDDEN>) id 1p0l8f-0002iL-0d for bug-gnu-emacs@HIDDEN; Thu, 01 Dec 2022 10:06:13 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <manikulin@HIDDEN>) id 1p0l8d-0008C4-0G for bug-gnu-emacs@HIDDEN; Thu, 01 Dec 2022 10:06:12 -0500 Received: by mail-lj1-x22b.google.com with SMTP id n1so2203546ljg.3 for <bug-gnu-emacs@HIDDEN>; Thu, 01 Dec 2022 07:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:from:to:cc:subject :date:message-id:reply-to; bh=6mdV/KlJ0hWR7r2/mVHZdz0v45EqWE/wSFnkgtnMxa0=; b=Noonw0gTBTfmyObS7KLMJkAV679TyHNClnhYU0JswEEgPc73NnMjwG7ugU1a5IeZCh Y4Sj40Dmjr7QeIfBLv/2Zfx+gjn7kqmPj2XEB7h1/SdV7F3kPu2/PDTSxKbN1q9Kw0tw KuficR24JalSvgNU8pLZSvUirWdJ4gznMJmpi8zlHnC/dKs4bRUAf9JASYbMIp8XfyRm gGf+W3sgzmgQ5nQH7hsPr9uaP+T0uzehREmbs6WrUbrVh7uj7IJlUF/WOfXTecq9ErKC ht9Je65unKMILgjqMYIxXR61P1aPg2ZG3r7AuJXsiLpsteLdboQ3mAxMjnwW/jS18He1 oZmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6mdV/KlJ0hWR7r2/mVHZdz0v45EqWE/wSFnkgtnMxa0=; b=sNPsiVj39KMNXIBmHlhLbocaX1dAxKZGEARHYr5Vx/S/7/FK8ICu1bIiLJlV0DTYz7 uw1FYhk8etaryaePeRDqJ/Xfp/b5MYp1xrnOOp6uinrbxbNP65NEVSHwuS6sJDmYDSvZ rVi26rbgNpX5FFzts/4qKO0GJIndNhY/AmApBrx/BqL9N3u2LiOb8XWKtLOpZDo7wwlV Zi40fmJMJxCKHsjzRF2Wrditcce6kyM/nDHCVNuwIz+0Gq4+FCd9ghogf4CeNwGHlPzp JekCrsd2heCkFdznmXjYFpqXqu74EuMIkn/tZjY+ZfYPNRNQcCyyAEsvUYzVHuFeQIoE AVtA== X-Gm-Message-State: ANoB5pmTtagqWvw457gnMn6jY7DYb5aidWns/lyQpqgJj8tx9lJHTIzB cI4f97JsqZ+pGpZlN9DYliZMrzbbDnk= X-Google-Smtp-Source: AA0mqf7KF9z9tKTFY0nogqYFxqmMEd8bIpRPf9kvqOsA0u3ym1/SzhheJBob8+iFfY/04lvq1l9Kbw== X-Received: by 2002:a2e:bf27:0:b0:279:74ab:77bd with SMTP id c39-20020a2ebf27000000b0027974ab77bdmr13326569ljr.380.1669907165458; Thu, 01 Dec 2022 07:06:05 -0800 (PST) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id h1-20020a056512220100b004b4e67c3c00sm674816lfu.53.2022.12.01.07.06.02 for <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 07:06:03 -0800 (PST) Message-ID: <438a7286-ee4c-74a1-c24b-d788a6507ad6@HIDDEN> Date: Thu, 1 Dec 2022 22:06:00 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: bug-gnu-emacs@HIDDEN From: Max Nikulin <manikulin@HIDDEN> Subject: Implement `command-line-args-left' for emacsclient --eval expressions Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=manikulin@HIDDEN; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) I propose to expand protocol of communication between emacsclient and server to allow passing of arbitrary arguments for --eval expression that are not treated as files. The goal is to pass strings to evaluated expressions in a safe way without necessity of escaping double quotes and backslashes. I suggest to add e,g, --args option of emacsclient that transfers everything after it (including arguments starting with dash) to server and causes let-binding the list to command-line-args-left (or another variable) before execution of preceding --eval options. It was briefly discussed in the following thread: Max Nikulin to emacs-orgmode. Re: Lazy load of org-protocol. Mon, 7 Feb 2022 21:57:09 +0700. https://list.orgmode.org/strc07$3o0$1@HIDDEN Such feature will allow to avoid the following complications: - A lot of backslashes are used to escape double quotes in http://git.savannah.gnu.org/cgit/emacs.git/tree/etc/emacsclient-mail.desktop --eval \\\\(message-mailto\\\\ \\\\\\"%u\\\\\\"\\\\) and this file still relies on desktop environment protection against shell special characters in the value of %u - org-protocol sets an advice to intercept file names containing components like org-protocol:/store-link?url=URL&title=TITLE It is a hack since current working directory is prepended when such URI is specified as an emacsclient argument. Autoloading currently is not implemented for this advice. - There are enough unsafe suggestions on the web to directly inject argument into elisp expression without proper escaping. Consider the following message: Gregory Heytings to emacs-devel. Re: How to get DISPLAY of emacsclient? Mon, 28 Nov 2022 17:15:28 +0000. https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01771.html mid:338f50d42149668a6b3a@HIDDEN emacsclient --eval '(progn (setq display "'$DISPLAY'") (princ display))' Despite probability of such event is rather low, accidentally DISPLAY value may be corrupted causing undesired effects of unsafe usage of the variable: - Word splitting is performed by shell after variable substitution. - If $DISPLAY is additionally wrapped into shell double quotes then something unexpected may still be executed by emacs DISPLAY=':0") (do-something-else) (ignore "' More examples of unsafe substitutions into evaluated expression: - https://www.reddit.com/r/emacs/comments/hhbcg7/emacsclient_eval_with_command_line_arguments/ - https://stackoverflow.com/questions/8848819/emacs-eval-ediff-1-2-how-to-put-this-line-in-to-shell-script the second link contains a recipe for proper quoting, but it is not in the accepted answer quoted1=${1//\\/\\\\}; quoted1=${quoted1//\"/\\\"} As an alternative, Jim Porter suggested an emacsclient option similar to emacs --funcall that should apply function to the following argument. I believe, if --args is implemented then it will be possible to define a helper function that combines function name and the command-line-args-left list. It will not require further extension of client-server protocol. Since the function to be applied must take strings arguments only, no integers or symbols are allowed, anyway wrapper functions to convert argument types will be required. That is why I do not expect real value of such apply feature. I hope, the emacsclient --eval "(message-mailto (car command-line-args-left))" \ --args mailto:bug-gnu-emacs@HIDDEN feature will make it easier to pass arguments to the evaluated expressions in a safe way.
Max Nikulin <manikulin@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#59743
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.