From unknown Fri Jun 13 11:39:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15285: url-data not working for base64-encoded data Resent-From: Klaus Straubinger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Sep 2013 09:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15285 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 15285@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.137845941226067 (code B ref -1); Fri, 06 Sep 2013 09:24:02 +0000 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?Mitteleurop=C3=A4ische?= Sommerzeit) From: Klaus Straubinger 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-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 unknown Fri Jun 13 11:39:52 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Klaus Straubinger Subject: bug#15285: closed (Re: bug#15285: url-data not working for base64-encoded data) Message-ID: References: X-Gnu-PR-Message: they-closed 15285 X-Gnu-PR-Package: emacs Reply-To: 15285@debbugs.gnu.org Date: Mon, 16 Sep 2013 21:32:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1379367123-14379-1" This is a multi-part message in MIME format... ------------=_1379367123-14379-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #15285: url-data not working for base64-encoded data which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 15285@debbugs.gnu.org. --=20 15285: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15285 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1379367123-14379-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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)))) ------------=_1379367123-14379-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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 ------------=_1379367123-14379-1--