From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ioannis Kappas Newsgroups: gmane.emacs.bugs Subject: bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings Date: Tue, 11 May 2021 07:52:02 +0100 Message-ID: References: <834kfmabvs.fsf@gnu.org> <83tunj651i.fsf@gnu.org> <83lf8u68bu.fsf@gnu.org> <83mtta4gtf.fsf@gnu.org> <83fsz24f2x.fsf@gnu.org> <83v97x2xum.fsf@gnu.org> <83bl9nevd3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36069"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48137@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 11 08:55:54 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 1lgMJ8-0009HA-4F for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 08:55:54 +0200 Original-Received: from localhost ([::1]:45556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgMJ6-0003g5-St for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 02:55:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgMGL-0007VY-WD for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 02:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgMGL-0001Ir-ON for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 02:53:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lgMGL-0007Yk-Nb for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 02:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ioannis Kappas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 May 2021 06:53: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.162071593928996 (code B ref 48137); Tue, 11 May 2021 06:53:01 +0000 Original-Received: (at 48137) by debbugs.gnu.org; 11 May 2021 06:52:19 +0000 Original-Received: from localhost ([127.0.0.1]:34833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgMFf-0007Xa-7t for submit@debbugs.gnu.org; Tue, 11 May 2021 02:52:19 -0400 Original-Received: from mail-ot1-f42.google.com ([209.85.210.42]:36810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgMFe-0007XO-2I for 48137@debbugs.gnu.org; Tue, 11 May 2021 02:52:18 -0400 Original-Received: by mail-ot1-f42.google.com with SMTP id n32-20020a9d1ea30000b02902a53d6ad4bdso16658066otn.3 for <48137@debbugs.gnu.org>; Mon, 10 May 2021 23:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IrlopOLAC8wL9MtUFkA86gYz6aoVDcVCuUMiiL34/R8=; b=sZj10WdTxb5XtYtIwU3EhuebshRDgFNFmCXf0odnZd/7uDKJGktKgHAECpaIYzPtFG DJ4MQkNECDG2pDEB/6h2V/aZwjzjA/5hz6oXWB6CMk8eW3y8Gw/cMd5KHdLyiGMNojW8 WKc2rEFissJAsBkNyF5FmAtiAxLrHrQBk/0Pi8kvhDJNyhjcasSeBrLHuiZ65n5PSJjh SfhQOq1Ct8BDc24gtKexEdzx3O1vgSXqHaALTuoVYGnILcAEwXy3DuZ8b8OMPLfg7Ck/ +BSxQEFlPTWjw+TVn/7k+8yLEyNGj5j8n5ZkPvL+xJlYM3fwOVlLmDiyWqRrCVJ2qMNC CcdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IrlopOLAC8wL9MtUFkA86gYz6aoVDcVCuUMiiL34/R8=; b=roLexPq4nDl1WkkJ9h8YXRh68+lakdF4AFBQdEcmrOGNRoyrY3UvVe6cYG8kiLDnbA cqTyWqP3MgiOHdyr6LLMmX2GgzINnfF28IjLze++GW57no+Rx8p0zGdIJliYrgPFUFa0 yJputU+rxztBp5QTgpc2vBkls/fJ6UXn157iEV7v8yO4Z+FpYNKa3TQo5pmEgQc8L7CX 4N3QKQdvFUhuBoPH4DLvTdU6aMmgmobwdWEBnDKMrxGBTABoS0gPBpOxpDGdPnpiPjWj egwU5svkmtIrLL9JrJi922KaC8ken1AoUsO5iM9oez8K48NwH8RGbaSfiB5TVKVwBBBE MrpA== X-Gm-Message-State: AOAM533Dq/dDM6qGoUPJHx5zTcIxJQKPqNUmhplnxaIxdlzyUR2jUo6m H6xR6mmH8lMB1XiRVBiAom2XnVYgXGq5LWM50iw= X-Google-Smtp-Source: ABdhPJwmdubQm5+zT4WoLhej0nq0ueki+YVYqlj3hDwRdiUruzSFRi5RTWVoX1/01Hb1JsMGNMAbhGjGEFQiKqAq8Fs= X-Received: by 2002:a9d:7e91:: with SMTP id m17mr24469920otp.192.1620715932360; Mon, 10 May 2021 23:52:12 -0700 (PDT) In-Reply-To: <83bl9nevd3.fsf@gnu.org> 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:206203 Archived-At: On Thu, May 6, 2021 at 4:26 PM Eli Zaretskii wrote: > > > From: Stefan Monnier > > Cc: Eli Zaretskii , 48137@debbugs.gnu.org > > Date: Thu, 06 May 2021 09:27:38 -0400 > > > > That's not sufficient, because if we don't decode the file before we > > call `package-buffer-info` (from `package-install-from-buffer`), then > > the -pkg.el file will have incorrect content (e.g. the non-ASCII > > chars in the description of the package, will be later incorrectly > > displayed in `list-packages`). > > So you are saying the description of the package needs to be decoded > before using it for list-packages? That'd be okay; all I care about > is that the decoded stuff does NOT replace the original raw bytes, but > instead is used only where decoding is needed. IOW, decoding should > either be done on substrings of the original file, and the result > stored in strings, or the decoded stuff should be placed in a separate > scratch buffer, which will be used only where decoding is really > needed. Is loading with `insert-file-contents' and saving as 'raw-text the same as copying the raw bytes of the original file? `hexlify-buffer' in 'hexl uses 'raw-text to display the raw bytes of an encoded buffer. I always assumed hexl displayed the actual binary representation of the underlying file. In which case, having `package-install-file' load the .el package file metaphorically and modifying `package-unpack' to store 'single files with 'raw-text should satisfy the requirement? Thus header parsing is done in the intended coding system, while the end package is a "copy" of the original. Example patch: diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index ecb2573cab..b5fa020179 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -932,7 +932,7 @@ package-unpack ('single (let ((el-file (expand-file-name (format "%s.el" name) pkg-dir))) (make-directory pkg-dir t) - (package--write-file-no-coding el-file))) + (package--write-file-raw-text el-file))) (kind (error "Unknown package kind: %S" kind))) (package--make-autoloads-and-stuff pkg-desc pkg-dir) ;; Update package-alist. @@ -1180,9 +1180,9 @@ package-dir-info ;; Set of low-level functions for communicating with archives and ;; signature checking. -(defun package--write-file-no-coding (file-name) +(defun package--write-file-raw-text (file-name) "Write file FILE-NAME without encoding using coding system." - (let ((buffer-file-coding-system 'no-conversion)) + (let ((buffer-file-coding-system 'raw-text)) (write-region (point-min) (point-max) file-name nil 'silent))) (declare-function url-http-file-exists-p "url-http" (url)) @@ -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))) Btw, https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-System-Basics.html mentions about the 'no-conversion coding system: no-conversion (and its alias binary) is equivalent to raw-text-unix: it specifies no conversion of either character codes or end-of-line. but since it is -unix, it does do EOL conversions to LF. Should the above be corrected to something like: no-conversion (and its alias binary) is equivalent to raw-text-unix: it specifies no conversion of character codes but converts end-of-lines to the unix convention. Thanks