GNU bug report logs - #17549
24.4.50; regression: url-insert-file-contents

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Thu, 22 May 2014 11:14:01 UTC

Severity: important

Found in version 24.4.50

Fixed in version 24.3.92

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 17549 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 17549 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#17549: 24.4.50; regression: url-insert-file-contents
Date: Wed, 25 Jun 2014 08:58:49 +0800
On 2014-06-24 16:01 +0200, Juanma Barranquero wrote:
> Sorry. I keep trying to find time to fix this and a few other bugs, but I'm
> very busy right now.

No worries ;)

> AFAIR, originally I wanted a small change, just throw an error in a
> specific case, and Stefan pushed for a bigger (though, I suppose, cleaner)
> fix; there was some back-and-forth and we finally settled on what's
> installed. So perhaps you can go back, reread the bug thread and find
> something in the proposed solutions that fixes the original problem and
> does not cause the one you're reporting.

OK, I read that thread quickly and now understood the decision. I
propose the following solution for now. The patch introduces a compiler
warning on url-http-codes. How best to suppress it?

=== modified file 'lisp/url/url-handlers.el'
--- lisp/url/url-handlers.el	2014-05-12 06:59:30 +0000
+++ lisp/url/url-handlers.el	2014-06-25 00:41:33 +0000
@@ -33,7 +33,6 @@
 (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))
@@ -313,12 +312,12 @@
   (let ((buffer (url-retrieve-synchronously url)))
     (unless buffer (signal 'file-error (list url "No Data")))
     (with-current-buffer buffer
-      (let ((response (url-http-parse-response)))
-        (if (and (>= response 200) (< response 300))
-            (goto-char (point-min))
-          (let ((desc (buffer-substring-no-properties (1+ (point))
-                                                      (line-end-position))))
+      (when (bound-and-true-p url-http-response-status)
+        (unless (and (>= url-http-response-status 200)
+                     (< url-http-response-status 300))
+          (let ((desc (nth 2 (assq url-http-response-status url-http-codes))))
             (kill-buffer buffer)
+            ;; Signal file-error per http://debbugs.gnu.org/16733.
             (signal 'file-error (list url desc))))))
     (if visit (setq buffer-file-name url))
     (save-excursion
@@ -333,6 +332,7 @@
           ;; 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))))))
+
 (put 'insert-file-contents 'url-file-handlers 'url-insert-file-contents)
 
 (defun url-file-name-completion (url directory &optional predicate)

=== modified file 'lisp/url/url-http.el'
--- lisp/url/url-http.el	2014-03-29 00:55:44 +0000
+++ lisp/url/url-http.el	2014-06-25 00:23:24 +0000
@@ -48,7 +48,6 @@
 (defvar url-http-response-version)
 (defvar url-http-target-url)
 (defvar url-http-transfer-encoding)
-(defvar url-http-end-of-headers)
 (defvar url-show-status)
 
 (require 'url-gw)




This bug report was last modified 10 years and 336 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.