From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#30243: 26.0.91; Infinite recursion in `make-auto-save-file-name' for quoted filenames Date: Tue, 30 Jan 2018 19:01:52 -0500 Message-ID: <87inbij3pr.fsf@users.sourceforge.net> References: <87shaun9ix.fsf@users.sourceforge.net> <87po5ymqed.fsf@users.sourceforge.net> <874lnafeun.fsf@gmx.de> <87mv12m3q6.fsf@users.sourceforge.net> <877es528vp.fsf@gmx.de> <87h8r9mlxx.fsf@users.sourceforge.net> <871sichok1.fsf@gmx.de> <87372qz395.fsf@gmx.de> <87shaqkp2q.fsf@users.sourceforge.net> <83mv0vh32y.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1517358618 19907 195.159.176.226 (31 Jan 2018 00:30:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Jan 2018 00:30:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 30243@debbugs.gnu.org, michael.albinus@gmx.de To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 31 01:30:14 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eggHw-0004Zo-3a for geb-bug-gnu-emacs@m.gmane.org; Wed, 31 Jan 2018 01:30:08 +0100 Original-Received: from localhost ([::1]:47687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eggJx-00045P-2q for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Jan 2018 19:32:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eggJe-00041R-Lf for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2018 19:31:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eggJZ-0006o0-OX for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2018 19:31:54 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eggJZ-0006ni-Jv for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2018 19:31:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egfrh-0001RI-Ol for bug-gnu-emacs@gnu.org; Tue, 30 Jan 2018 19:03:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 31 Jan 2018 00:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30243 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30243-submit@debbugs.gnu.org id=B30243.15173569235457 (code B ref 30243); Wed, 31 Jan 2018 00:03:01 +0000 Original-Received: (at 30243) by debbugs.gnu.org; 31 Jan 2018 00:02:03 +0000 Original-Received: from localhost ([127.0.0.1]:49982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egfqk-0001Px-R7 for submit@debbugs.gnu.org; Tue, 30 Jan 2018 19:02:03 -0500 Original-Received: from mail-io0-f172.google.com ([209.85.223.172]:43768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egfqj-0001PU-Jc for 30243@debbugs.gnu.org; Tue, 30 Jan 2018 19:02:02 -0500 Original-Received: by mail-io0-f172.google.com with SMTP id 72so13400996iom.10 for <30243@debbugs.gnu.org>; Tue, 30 Jan 2018 16:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=m27RNY9/rrhbVvk3RkzZFPYHvrXpX3s3ovsIVnDROLo=; b=Kyl86FnDsbSB1ZwrDTvDnsiA4H+yT7ndEC7kpaEcdAxdYkCVpYq+Iv9kkTUyVrxLk3 4lm1n0uGx1qPnh5+E4AtMfdejGTMWRHnvbpXZ2FlJ4E6ec9q5Ce57FL6yJ6LlIPXx87C nAYvQpHsv61sgPaxUOpNxW+O504e49tvm8eoro8CmR1+NRYoDoEZVMc4bwIYg+Tqt6kH FtWjqXp2wnDvAzEK1OUZS/EdVMlQZBEnQNkW14z90mgAxwtwL9gLD3poB2rx3sSJhM6a 9NyZoxTEnP0NT1z7k3Xpq65bdyvjLhwV2TmDpp/4VB75UCf9J8XVXQHd5lv/+m6p7+xt dYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=m27RNY9/rrhbVvk3RkzZFPYHvrXpX3s3ovsIVnDROLo=; b=lsdMYGpotn1Ip2LScZlcxFn0BdBZToFv1NDwZLkaUj2y04SaxxwCwSKgqMx4w9PBe7 747uKWqIL3OsHFnsM52mNY4iAwMd53XOTDntbDPgC3Tzmh+avy0TYBJyGliaOeb9BNfg +N+3BCRkVgh5AyAKO4pzSWXKHZQKBy8eQ0+Vf8X/kV/0GWXSq1NWAe8AELj1hsIB+7sv HljAXSvUYYmlnwm6vIEtKuvCQWtal+aTBfZhpvYzzwfcYupqI/NFb4+3lzoCtR+lT27z Jk2g0o9tSRobTbWDvlDJI5LGL3z9kTFAjxYThqCiv/Rp5/Ulg2egjnPqGZe5kakszWen GrkA== X-Gm-Message-State: AKwxytcePQh012RyRPf5+MPqx2N1eHYaq0qDsPxiSd6fQ6znJt6a7wVz oaHSODnCGLDZQa4hhhs0xB4= X-Google-Smtp-Source: AH8x225GaJXfwqx7EJJ5X8FAijvVwHDCv/nPVZKrts7JWHwrhlijVMX4f26LGvLzlSoYzjInw7HHHg== X-Received: by 10.107.175.103 with SMTP id y100mr19420663ioe.45.1517356915804; Tue, 30 Jan 2018 16:01:55 -0800 (PST) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 97sm6540465ioh.31.2018.01.30.16.01.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jan 2018 16:01:54 -0800 (PST) In-Reply-To: (Philipp Stephani's message of "Tue, 30 Jan 2018 19:22:34 +0000") 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:142715 Archived-At: Philipp Stephani writes: > If my git bisect is correct, it was > commit=C2=A0a1bbc490155b61a634a6d0b165000ce35b93aa35 to fix=C2=A0Bug#2957= 9. So > by fixing one bug we introduced another one :( Actually, looking at Bug#29579 again, it doesn't seem *that* bad, and as far as I can tell, it has existed for a long time (still occurs back in 24.3). So reverting that fix seems like a reasonable option too. I can confirm that doing so fixes this bug. > Eli Zaretskii schrieb am Di., 30. Jan. 2018 um > 14:46=C2=A0Uhr: >=20=20=20=20 > I think to make up my mind I'd need a few words about each part of > the changes (with the exception of the test suite changes): why is > each of them needed, and what does it do to fix which part of the > original problem. The file-name-non-special function handles all file-handler operations for "/:" quoted files. It has an alist inside, to decide which arguments are filenames and so require the "/:" to be removed before calling the real operation. The alist was not complete, so for many operations the "/:" would only be stripped from the first argument (that's a fallback for operations not listed in the alist). Up until the fix for Bug#29579 this didn't matter so much, because file-name-non-special would bind file-name-handler-alist to nil, thus preventing any further filenames from being passed to the handler anyway. So multi-filename-arg handlers were broken, but unobtrusively so. With the fix for Bug#29579, such handlers got stuck in infinite recursion, as they kept getting called, not stripping the "/:" prefix, thus getting called again, etc... The proposed patch just fixes up this alist to finally list all the arguments for all the handlers correctly: @@ -7000,7 +7000,7 @@ file-name-non-special ;; Bug#25949. (if (memq operation '(insert-directory process-file start-file-process - shell-command)) + shell-command temporary-file-direc= tory)) (directory-file-name (expand-file-name (unhandled-file-name-directory default-directory))) @@ -7024,15 +7024,23 @@ file-name-non-special ;; temporarily to unquoted filename. (verify-visited-file-modtime unquote-then-quote) ;; List the arguments which are filenames. - (file-name-completion 1) - (file-name-all-completions 1) + (file-name-completion 0 1) + (file-name-all-completions 0 1) + (file-equal-p 0 1) + (file-newer-than-file-p 0 1) (write-region 2 5) (rename-file 0 1) (copy-file 0 1) (copy-directory 0 1) (file-in-directory-p 0 1) (make-symbolic-link 0 1) - (add-name-to-file 0 1)))) + (add-name-to-file 0 1) + (make-auto-save-file-name buffer-file-name) + (set-visited-file-modtime buffer-file-name) + ;; These file-notify-* operations take a + ;; descriptor. + (file-notify-rm-watch . nil) + (file-notify-valid-p . nil)))) ;; For all other operations, treat the first argument only ;; as the file name. '(nil 0)))) @@ -7055,6 +7063,12 @@ file-name-non-special (pcase method (`identity (car arguments)) (`add (file-name-quote (apply operation arguments))) + (`buffer-file-name + (let ((buffer-file-name + (if (string-match "\\`/:" buffer-file-name) + (substring buffer-file-name (match-end 0)) + buffer-file-name))) + (apply operation arguments))) (`insert-file-contents (let ((visit (nth 1 arguments))) (unwind-protect > I also wonder how come we've succeeded to break quoted file names > so fundamentally -- what change did that, and why did we make it > on the release branch? IMO, the root cause is pretty clearly lack of adequate tests for this. There are more than 60 file-handler operations; it's crazy to expect to be able to make a correct change without an automated test that at least exercises each one.