From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#8035: Processing of .. in a file path after going thru symlink Date: Thu, 26 Aug 2021 20:30:29 +0300 Message-ID: <83k0k8ru4q.fsf@gnu.org> References: <30918394.post@talk.nabble.com> <877dg8yxrx.fsf@gnus.org> <83sfywrw9w.fsf@gnu.org> <87sfywxhnn.fsf@gnus.org> <83mtp4rv5d.fsf@gnu.org> <87czq0xgoj.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33779"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 8035@debbugs.gnu.org, slpnabble@blackberry-hill.com To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 26 19:31:17 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJJDh-0008bO-1j for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 19:31:17 +0200 Original-Received: from localhost ([::1]:42086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJJDf-0005IC-50 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 13:31:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJJDS-0005FU-LY for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJJDS-0001LE-Bm for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJJDS-00019T-7q for bug-gnu-emacs@gnu.org; Thu, 26 Aug 2021 13:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Aug 2021 17:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8035 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 8035-submit@debbugs.gnu.org id=B8035.16299990584410 (code B ref 8035); Thu, 26 Aug 2021 17:31:02 +0000 Original-Received: (at 8035) by debbugs.gnu.org; 26 Aug 2021 17:30:58 +0000 Original-Received: from localhost ([127.0.0.1]:50353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJJDO-000194-H2 for submit@debbugs.gnu.org; Thu, 26 Aug 2021 13:30:58 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJJDM-00018p-8a for 8035@debbugs.gnu.org; Thu, 26 Aug 2021 13:30:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44092) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJJDG-0001Dy-Dh; Thu, 26 Aug 2021 13:30:50 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1088 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJJDF-0001ox-Oi; Thu, 26 Aug 2021 13:30:50 -0400 In-Reply-To: <87czq0xgoj.fsf@gnus.org> (message from Lars Ingebrigtsen on Thu, 26 Aug 2021 19:24:28 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:212741 Archived-At: > From: Lars Ingebrigtsen > Cc: slpnabble@blackberry-hill.com, 8035@debbugs.gnu.org > Date: Thu, 26 Aug 2021 19:24:28 +0200 > > Eli Zaretskii writes: > > > expand-file-name also normalizes file names, though. Which is also > > needed in some use cases, e.g. when the /foo/bar/ isn't accessible, > > but /foo/ is, in which case failing to normalize /foo/bar/../quux > > could fail some file I/O function. > > Hm, yes, that's a point... The OP's use case is clearly documented in the ELisp manual: Note also that ‘expand-file-name’ does not follow symbolic links at any level. This results in a difference between the way ‘file-truename’ and ‘expand-file-name’ treat ‘..’. Assuming that ‘/tmp/bar’ is a symbolic link to the directory ‘/tmp/foo/bar’ we get: (file-truename "/tmp/bar/../myfile") ⇒ "/tmp/foo/myfile" (expand-file-name "/tmp/bar/../myfile") ⇒ "/tmp/myfile" If you may need to follow symbolic links preceding ‘..’, you should make sure to call ‘file-truename’ without prior direct or indirect calls to ‘expand-file-name’. *Note Truenames::. So I think we need to use file-truename if we want to support such uses of symlinks in "M-x compile" etc.