From unknown Fri Jun 13 10:08:53 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#15285 <15285@debbugs.gnu.org> To: bug#15285 <15285@debbugs.gnu.org> Subject: Status: url-data not working for base64-encoded data Reply-To: bug#15285 <15285@debbugs.gnu.org> Date: Fri, 13 Jun 2025 17:08:53 +0000 retitle 15285 url-data not working for base64-encoded data reassign 15285 emacs submitter 15285 Klaus Straubinger severity 15285 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 06 05:23:32 2013 Received: (at submit) by debbugs.gnu.org; 6 Sep 2013 09:23:32 +0000 Received: from localhost ([127.0.0.1]:43087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VHsGJ-0006mM-3f for submit@debbugs.gnu.org; Fri, 06 Sep 2013 05:23:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33992) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VHsGG-0006m7-4t for submit@debbugs.gnu.org; Fri, 06 Sep 2013 05:23:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHsG2-0002Na-LY for submit@debbugs.gnu.org; Fri, 06 Sep 2013 05:23:23 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHsG2-0002NW-IX for submit@debbugs.gnu.org; Fri, 06 Sep 2013 05:23:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHsFw-0003Y4-JG for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 05:23:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHsFq-0002Jd-KU for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 05:23:08 -0400 Received: from smtpde02.sap-ag.de ([155.56.68.140]:53606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHsFq-0002Hu-CH for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2013 05:23:02 -0400 Received: from mail05.wdf.sap.corp by smtpde02.sap-ag.de (26) with ESMTP id r869Mxm3020045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Sep 2013 11:22:59 +0200 (MEST) Message-ID: Date: Fri, 6 Sep 2013 11:22:59 +0200 =?utf-8?Q?=28Mitteleurop=C3=A4ische?= Sommerzeit) From: Klaus Straubinger To: bug-gnu-emacs@gnu.org Subject: url-data not working for base64-encoded data MIME-Version: 1.0 Content-Type: text/plain Content-Language: de-DE X-Mailer: Gnus/5.13 (Gnus v5.13) Emacs/24.3 X-SAP: out X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 16 17:31:59 2013 Received: (at 15285-done) by debbugs.gnu.org; 16 Sep 2013 21:31:59 +0000 Received: from localhost ([127.0.0.1]:41925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VLgOk-0003jZ-HU for submit@debbugs.gnu.org; Mon, 16 Sep 2013 17:31:59 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:56106 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VLgOi-0003jQ-1E for 15285-done@debbugs.gnu.org; Mon, 16 Sep 2013 17:31:56 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1VLgOh-0001bx-2a; Mon, 16 Sep 2013 17:31:55 -0400 From: Glenn Morris To: 15285-done@debbugs.gnu.org Subject: Re: bug#15285: url-data not working for base64-encoded data References: X-Spook: Islam Abduganievich Karimov military ammunition analyzer X-Ran: C#0]xx@K*4;]yIKvYA(RQ5FU";hppzd*k)Kr(nh{.(0Z3=H7r({;$PNVdRVub`[@9lB923 X-Hue: black X-Debbugs-No-Ack: yes X-Attribution: GM Date: Mon, 16 Sep 2013 17:31:54 -0400 In-Reply-To: (Klaus Straubinger's message of "Fri, 6 Sep 2013 11:22:59 +0200 =?utf-8?Q?=28Mitteleurop=C3=A4?= =?utf-8?Q?ische?= Sommerzeit)") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 15285-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.7 (-----) 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)))) From unknown Fri Jun 13 10:08:53 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 15 Oct 2013 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator