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#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings Date: Tue, 04 May 2021 14:39:02 +0300 Message-ID: <83im3y684p.fsf@gnu.org> References: <834kfmabvs.fsf@gnu.org> <83tunj651i.fsf@gnu.org> <83r1in645l.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ioannis.kappas@gmail.com, 48137@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 04 13:40:33 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 1ldtPl-00018t-Rf for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 13:40:33 +0200 Original-Received: from localhost ([::1]:57230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldtPk-00057E-Tz for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 07:40:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldtPF-00054C-Ti for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 07:40:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldtPF-0000Ov-Kv for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 07:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldtPF-0004b0-Hx for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 07:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 May 2021 11:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48137 X-GNU-PR-Package: emacs Original-Received: via spool by 48137-submit@debbugs.gnu.org id=B48137.162012838117654 (code B ref 48137); Tue, 04 May 2021 11:40:01 +0000 Original-Received: (at 48137) by debbugs.gnu.org; 4 May 2021 11:39:41 +0000 Original-Received: from localhost ([127.0.0.1]:52707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldtOm-0004ag-OD for submit@debbugs.gnu.org; Tue, 04 May 2021 07:39:41 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldtOj-0004aa-WE for 48137@debbugs.gnu.org; Tue, 04 May 2021 07:39:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49614) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldtOd-00006a-Hh; Tue, 04 May 2021 07:39:24 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4052 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ldtOV-00074K-FO; Tue, 04 May 2021 07:39:22 -0400 In-Reply-To: (message from Stefan Monnier on Mon, 03 May 2021 16:12:17 -0400) 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:205597 Archived-At: > From: Stefan Monnier > Cc: Ioannis Kappas , 48137@debbugs.gnu.org > Date: Mon, 03 May 2021 16:12:17 -0400 > > >> If not, I would like to suggest a slightly > >> updated patch that is targeting .el files directly as an exemption: > >> > >> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el > >> index ecb2573cab..19ab0445b9 100644 > >> --- a/lisp/emacs-lisp/package.el > >> +++ b/lisp/emacs-lisp/package.el > >> @@ -2147,7 +2147,9 @@ package-install-file > >> (progn > >> (setq default-directory file) > >> (dired-mode)) > >> - (insert-file-contents-literally file) > >> + (if (string-match "\\.el\\'" file) > >> + (insert-file-contents file) > >> + (insert-file-contents-literally file)) > >> (when (string-match "\\.tar\\'" file) (tar-mode))) > >> (package-install-from-buffer))) > > > > is not something I can endorse, especially as it decodes much more > > than just the EOL format. > > package.el should do *some* decoding because it needs to look at > the pseudo-headers in the file to generate the `-pkg.el` which > contains among other things the package's short description. That's not "decoding" in the sense I used it, which is when we _replace_ in memory the original raw bytes with the decoded contents. "Decoding" for the purpose of parsing some part of the file is fine, especially since here it just needs to be prepared to having an optional CR before each LF. (In fact, I'd be also okay with decoding all of it into a temporary buffer, though that would probably be waste of cycles.) > Admittedly, these will usually work OK in undecoded buffers as well, > but not in all cases. In what cases this would not work? Can those cases be handled by directing the decoded stuff to a destination that is not the original text, thus keeping the original text unaltered?