From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#16733: messed up unicode chars in package description Date: Sat, 22 Mar 2014 02:11:51 +0100 Message-ID: References: <7tfvnn7phj.fsf@fencepost.gnu.org> <83zjkm865z.fsf@gnu.org> <838us496xy.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1395450792 4117 80.91.229.3 (22 Mar 2014 01:13:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Mar 2014 01:13:12 +0000 (UTC) Cc: 16733@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 22 02:13:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WRAUx-0006p8-64 for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Mar 2014 02:13:19 +0100 Original-Received: from localhost ([::1]:55303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRAUw-0002Os-Df for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Mar 2014 21:13:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRAUm-0002Mr-Ur for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 21:13:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRAUg-0003Iu-Td for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 21:13:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42849) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRAUg-0003Ip-P0 for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 21:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WRAUg-0007oy-DA for bug-gnu-emacs@gnu.org; Fri, 21 Mar 2014 21:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Mar 2014 01:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16733 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16733-submit@debbugs.gnu.org id=B16733.139545075730015 (code B ref 16733); Sat, 22 Mar 2014 01:13:02 +0000 Original-Received: (at 16733) by debbugs.gnu.org; 22 Mar 2014 01:12:37 +0000 Original-Received: from localhost ([127.0.0.1]:44031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WRAUG-0007o3-Be for submit@debbugs.gnu.org; Fri, 21 Mar 2014 21:12:36 -0400 Original-Received: from mail-yh0-f43.google.com ([209.85.213.43]:33277) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WRAUD-0007nt-9V for 16733@debbugs.gnu.org; Fri, 21 Mar 2014 21:12:33 -0400 Original-Received: by mail-yh0-f43.google.com with SMTP id b6so3191226yha.30 for <16733@debbugs.gnu.org>; Fri, 21 Mar 2014 18:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=8pCNg/g9cp9O148IhA4qBGxyk+oMBNKdioVNDujOfMU=; b=tVtZv5lWbCKXz9qYn1kttbm4kFO4qR5YQYjrVKqnbTTq4ILUUQnJCsrfTF84mZ5rKc W1b+2N5Vwbv3qJU5In6oiu/LXzwbWwqAMp11prr2cfE/QVP0usz78BSaCjPO/MBrppIP uHucr8l3XVSoafX5zbGIRmKTg+KflpPgvd0tSDxyw9RoYl+0GvlSoms7CcNWyInTHNDM Vs7f28FzR2BE0hPxjNi64KOCke0XAycfz+HcT0lpeP1nLUM1VZ/SeBi2bOGcy9LVFE8m 0Cb24pOUZmQO5bxp+3RwHcTIgW7BwUdPF/pZevgMfHjXu4q5hbBp+QBfy3VKCkpCFAsm FKHw== X-Received: by 10.236.128.47 with SMTP id e35mr339406yhi.96.1395450752829; Fri, 21 Mar 2014 18:12:32 -0700 (PDT) Original-Received: by 10.170.163.3 with HTTP; Fri, 21 Mar 2014 18:11:51 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:87127 Archived-At: A possible fix for trunk, not the release branch. Basically, the idea is to move most functionality from url-insert-file-contents to a new url-insert-file-contents-internal, which has an additional arg, a check function (possibly nil). That function is called with the same parameters that url-insert-file-contents plus the url buffer (with response codes, etc.) returned by url-retrieve-synchronously. The original u-i-f-c turns into a wrapper for u-i-f-c-internal, and package--with-work-buffer can call u-i-f-c-internal and leverage package-handle-response to check for errors. (If we can assume that package-handle-response isn't used outside package.el, a further simplification is possible.) J === modified file 'lisp/emacs-lisp/package.el' --- lisp/emacs-lisp/package.el 2014-03-21 06:06:52 +0000 +++ lisp/emacs-lisp/package.el 2014-03-22 00:48:26 +0000 @@ -770,24 +770,20 @@ and evaluates BODY while that buffer is current. This work buffer is killed afterwards. Return the last value in BODY." (declare (indent 2) (debug t)) - `(let* ((http (string-match "\\`https?:" ,location)) - (buffer - (if http - (url-retrieve-synchronously (concat ,location ,file)) - (generate-new-buffer "*package work buffer*")))) - (prog1 - (with-current-buffer buffer - (if http - (progn (package-handle-response) - (re-search-forward "^$" nil 'move) - (forward-char) - (delete-region (point-min) (point))) - (unless (file-name-absolute-p ,location) - (error "Archive location %s is not an absolute file name" - ,location)) - (insert-file-contents (expand-file-name ,file ,location))) - ,@body) - (kill-buffer buffer)))) + `(with-temp-buffer + (if (string-match-p "\\`https?:" ,location) + (progn + (require 'url-handlers) + (url-insert-file-contents-internal + (lambda (buffer &rest _) + (with-current-buffer buffer (package-handle-response))) + (concat ,location ,file)) + (goto-char (point-min))) + (unless (file-name-absolute-p ,location) + (error "Archive location %s is not an absolute file name" + ,location)) + (insert-file-contents (expand-file-name ,file ,location))) + ,@body)) (defun package-handle-response () "Handle the response from a `url-retrieve-synchronously' call. @@ -1272,7 +1268,7 @@ (car archive))))) ;; Read the retrieved buffer to make sure it is valid (e.g. it ;; may fetch a URL redirect page). - (when (listp (read buffer)) + (when (listp (read (current-buffer))) (make-directory dir t) (setq buffer-file-name (expand-file-name file dir)) (let ((version-control 'never) @@ -1531,8 +1527,7 @@ (setq readme-string (buffer-string)) t)) (error nil)) - (let ((coding (detect-coding-string readme-string t))) - (insert (decode-coding-string readme-string coding t)))) + (insert readme-string)) ((file-readable-p readme) (insert-file-contents readme) (goto-char (point-max)))))))) === modified file 'lisp/url/url-handlers.el' --- lisp/url/url-handlers.el 2014-01-01 07:43:34 +0000 +++ lisp/url/url-handlers.el 2014-03-22 00:53:21 +0000 @@ -290,11 +290,12 @@ (insert data)) (list (length data) charset))) -;;;###autoload -(defun url-insert-file-contents (url &optional visit beg end replace) +(defun url-insert-file-contents-internal (check url &optional visit beg end replace) (let ((buffer (url-retrieve-synchronously url))) - (if (not buffer) - (error "Opening input file: No such file or directory, %s" url)) + (when check + (unwind-protect + (funcall check buffer url visit beg end replace) + (when buffer (kill-buffer)))) (if visit (setq buffer-file-name url)) (save-excursion (let* ((start (point)) @@ -308,6 +309,14 @@ ;; usual heuristic/rules that we apply to files. (decode-coding-inserted-region start (point) url visit beg end replace)) (list url (car size-and-charset)))))) + +;;;###autoload +(defun url-insert-file-contents (url &optional visit beg end replace) + (url-insert-file-contents-internal + (lambda (buffer url &rest _ignore) + (unless buffer + (error "Opening input file: No such file or directory, %s" url))) + url visit beg end replace)) (put 'insert-file-contents 'url-file-handlers 'url-insert-file-contents) (defun url-file-name-completion (url directory &optional predicate)