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: Tue, 25 Mar 2014 04:04:10 +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 1395716710 5854 80.91.229.3 (25 Mar 2014 03:05:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Mar 2014 03:05:10 +0000 (UTC) Cc: 16733@debbugs.gnu.org To: Stefan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 25 04:05: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 1WSHfz-00036X-IK for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Mar 2014 04:05:19 +0100 Original-Received: from localhost ([::1]:39422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSHfz-0007eA-2U for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Mar 2014 23:05:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSHfp-0007bF-EX for bug-gnu-emacs@gnu.org; Mon, 24 Mar 2014 23:05:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSHfk-0001zU-8O for bug-gnu-emacs@gnu.org; Mon, 24 Mar 2014 23:05:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSHfk-0001xa-5L for bug-gnu-emacs@gnu.org; Mon, 24 Mar 2014 23:05:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WSHfj-0005Ew-11 for bug-gnu-emacs@gnu.org; Mon, 24 Mar 2014 23:05:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Mar 2014 03:05: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.139571669620123 (code B ref 16733); Tue, 25 Mar 2014 03:05:02 +0000 Original-Received: (at 16733) by debbugs.gnu.org; 25 Mar 2014 03:04:56 +0000 Original-Received: from localhost ([127.0.0.1]:48305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WSHfb-0005EU-0k for submit@debbugs.gnu.org; Mon, 24 Mar 2014 23:04:55 -0400 Original-Received: from mail-yh0-f43.google.com ([209.85.213.43]:50542) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WSHfX-0005EH-Cp for 16733@debbugs.gnu.org; Mon, 24 Mar 2014 23:04:52 -0400 Original-Received: by mail-yh0-f43.google.com with SMTP id b6so6079500yha.16 for <16733@debbugs.gnu.org>; Mon, 24 Mar 2014 20:04:50 -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=fnM9N434TOv3Rfr7JrpG/OoqcfgsdLq3uPCOWr7Sahk=; b=HFvR+wlwxUrwTO0OQ2o6irvp70mE4krJl4QuEBZlP2mXhtsv1qDaIdxFKjaV18UmNJ qTE6hZGxvgYtLi5Ouf4Nv5zcaQv6FM+UWcg5NJui1R1AHHaW9syYYsVqXC92T4QVCdgW 1qJHyiBpTcs88REQ002TlF8P31W6QWe4fOoEyy4M/Sp1BYT3fIVEgyydxfusZBX++XKu 9IqKuoq4IHNZmHYZt5EVbmEDjvifm6nmG69c6llMwHYZtohCFVncVwx7my/Xl/GRiImJ Y1J9ViE/SATrNgfjbxQBv0raxegp2SWC47SxZHmzBZHJjXx/U0Ny8PiFo0rPSjIr8htD MkpQ== X-Received: by 10.236.75.162 with SMTP id z22mr26895153yhd.32.1395716690868; Mon, 24 Mar 2014 20:04:50 -0700 (PDT) Original-Received: by 10.170.163.3 with HTTP; Mon, 24 Mar 2014 20:04:10 -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:87344 Archived-At: 2014-03-25 Juanma Barranquero * url-handlers.el (url-http-parse-response): Add autoload. (url-insert-file-contents): Signal file-error in case of HTTP error. * emacs-lisp/package.el (url-http-parse-response) (url-http-end-of-headers, url-recreate-url, url-http-target-url): Remove unused declarations. (package-handle-response): Remove. (package--with-work-buffer): Use url-insert-file-contents and simplify. (package--download-one-archive): Use current-buffer instead of dynamic binding of `buffer'. (describe-package-1): Do not decode readme-string. === 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-25 02:44:43 +0000 @@ -33,6 +33,7 @@ (autoload 'url-expand-file-name "url-expand" "Convert url to a fully specified url, and canonicalize it.") (autoload 'mm-dissect-buffer "mm-decode" "Dissect the current buffer and return a list of MIME handles.") (autoload 'url-scheme-get-property "url-methods" "Get property of a URL SCHEME.") +(autoload 'url-http-parse-response "url-http" "Parse just the response code.") ;; Always used after mm-dissect-buffer and defined in the same file. (declare-function mm-save-part-to-file "mm-decode" (handle file)) @@ -293,21 +294,27 @@ ;;;###autoload (defun url-insert-file-contents (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)) - (if visit (setq buffer-file-name url)) - (save-excursion - (let* ((start (point)) - (size-and-charset (url-insert buffer beg end))) - (kill-buffer buffer) - (when replace - (delete-region (point-min) start) - (delete-region (point) (point-max))) - (unless (cadr size-and-charset) - ;; If the headers don't specify any particular charset, use the - ;; 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)))))) + (unwind-protect + (progn + (when (or (not buffer) + (with-current-buffer buffer + (let ((response (url-http-parse-response))) + (goto-char (point-min)) + (or (< response 200) (>= response 300))))) + (signal 'file-error `("Opening input URL" ,url))) + (if visit (setq buffer-file-name url)) + (save-excursion + (let* ((start (point)) + (size-and-charset (url-insert buffer beg end))) + (when replace + (delete-region (point-min) start) + (delete-region (point) (point-max))) + (unless (cadr size-and-charset) + ;; If the headers don't specify any particular charset, use the + ;; 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))))) + (when buffer (kill-buffer buffer))))) (put 'insert-file-contents 'url-file-handlers 'url-insert-file-contents) (defun url-file-name-completion (url directory &optional predicate) === modified file 'lisp/emacs-lisp/package.el' --- lisp/emacs-lisp/package.el 2014-03-22 08:43:30 +0000 +++ lisp/emacs-lisp/package.el 2014-03-25 02:46:22 +0000 @@ -205,13 +205,9 @@ (defvar Info-directory-list) (declare-function info-initialize "info" ()) -(declare-function url-http-parse-response "url-http" ()) (declare-function url-http-file-exists-p "url-http" (url)) (declare-function lm-header "lisp-mnt" (header)) (declare-function lm-commentary "lisp-mnt" (&optional file)) -(defvar url-http-end-of-headers) -(declare-function url-recreate-url "url-parse" (urlobj)) -(defvar url-http-target-url) (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/")) "An alist of archives from which to fetch. @@ -770,38 +766,14 @@ 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)))) - -(defun package-handle-response () - "Handle the response from a `url-retrieve-synchronously' call. -Parse the HTTP response and throw if an error occurred. -The url package seems to require extra processing for this. -This should be called in a `save-excursion', in the download buffer. -It will move point to somewhere in the headers." - ;; We assume HTTP here. - (require 'url-http) - (let ((response (url-http-parse-response))) - (when (or (< response 200) (>= response 300)) - (error "Error downloading %s:%s" - (url-recreate-url url-http-target-url) - (buffer-substring-no-properties (point) (line-end-position)))))) + `(with-temp-buffer + (if (string-match-p "\\`https?:" ,location) + (url-insert-file-contents (concat ,location ,file)) + (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--archive-file-exists-p (location file) (let ((http (string-match "\\`https?:" location))) @@ -1272,7 +1244,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 +1503,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))))))))