GNU bug report logs - #15285
url-data not working for base64-encoded data

Previous Next

Package: emacs;

Reported by: Klaus Straubinger <KSNetz <at> UseNet.ArcorNews.DE>

Date: Fri, 6 Sep 2013 09:24:02 UTC

Severity: normal

Fixed in version 24.4

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15285 in the body.
You can then email your comments to 15285 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15285; Package emacs. (Fri, 06 Sep 2013 09:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Klaus Straubinger <KSNetz <at> UseNet.ArcorNews.DE>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 06 Sep 2013 09:24:02 GMT) Full text and rfc822 format available.

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

From: Klaus Straubinger <KSNetz <at> UseNet.ArcorNews.DE>
To: bug-gnu-emacs <at> gnu.org
Subject: url-data not working for base64-encoded data
Date: Fri, 6 Sep 2013 11:22:59 +0200 (Mitteleuropäische
 Sommerzeit)
In GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601),
evaluating

    (require 'mm-decode)
    (require 'url)
    (mm-display-part
     (with-current-buffer
         (url-retrieve-synchronously
          "data:image/x-portable-bitmap;base64,UDQKMTQgMTAK//zgHJAkiESHhItEkCSgFMAM//w=")
       (mm-dissect-buffer t)))

should insert a letter image into the current buffer, but this does not work.

The cause is that in the function url-data (defined in url-misc.el)
the handling of the base64 parameter moves the match end and so the
starting "," character gets into the data, making them invalid.

Furthermore, instead of inserting the header "Content-Encoding" (that
should be used for encodings like "gzip") the code should insert the
header "Content-Transfer-Encoding" (the correct one for "8bit" or "base64").

-- 
Klaus Straubinger




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Mon, 16 Sep 2013 21:32:02 GMT) Full text and rfc822 format available.

Notification sent to Klaus Straubinger <KSNetz <at> UseNet.ArcorNews.DE>:
bug acknowledged by developer. (Mon, 16 Sep 2013 21:32:03 GMT) Full text and rfc822 format available.

Message #10 received at 15285-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 15285-done <at> debbugs.gnu.org
Subject: Re: bug#15285: url-data not working for base64-encoded data
Date: Mon, 16 Sep 2013 17:31:54 -0400
Version: 24.4

Thanks for the clear report.
(I needed to add a "(require 'mm-view)" to the test-case).

I think this fixes it:

*** lisp/url/url-misc.el	2013-01-02 16:13:04 +0000
--- lisp/url/url-misc.el	2013-09-16 21:28:11 +0000
***************
*** 89,107 ****
      (save-excursion
        (if (not (string-match "\\([^,]*\\)?," desc))
  	  (error "Malformed data URL: %s" desc)
! 	(setq mediatype (match-string 1 desc))
  	(if (and mediatype (string-match ";base64\\'" mediatype))
  	    (setq mediatype (substring mediatype 0 (match-beginning 0))
  		  encoding "base64"))
  	(if (or (null mediatype)
  		(eq ?\; (aref mediatype 0)))
! 	  (setq mediatype (concat "text/plain" mediatype)))
! 	(setq data (url-unhex-string (substring desc (match-end 0)))))
        (set-buffer (generate-new-buffer " *url-data*"))
        (mm-disable-multibyte)
        (insert (format "Content-Length: %d\n" (length data))
  	      "Content-Type: " mediatype "\n"
! 	      "Content-Encoding: " encoding "\n"
  	      "\n")
        (if data (insert data))
        (current-buffer))))
--- 88,106 ----
      (save-excursion
        (if (not (string-match "\\([^,]*\\)?," desc))
  	  (error "Malformed data URL: %s" desc)
! 	(setq mediatype (match-string 1 desc)
! 	      data (url-unhex-string (substring desc (match-end 0))))
  	(if (and mediatype (string-match ";base64\\'" mediatype))
  	    (setq mediatype (substring mediatype 0 (match-beginning 0))
  		  encoding "base64"))
  	(if (or (null mediatype)
  		(eq ?\; (aref mediatype 0)))
! 	  (setq mediatype (concat "text/plain" mediatype))))
        (set-buffer (generate-new-buffer " *url-data*"))
        (mm-disable-multibyte)
        (insert (format "Content-Length: %d\n" (length data))
  	      "Content-Type: " mediatype "\n"
! 	      "Content-Transfer-Encoding: " encoding "\n"
  	      "\n")
        (if data (insert data))
        (current-buffer))))





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Oct 2013 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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