From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adolf Belka To: development@lists.ipfire.org Subject: [PATCH] logo.cgi: Fix for bug13795 - captive portal not displaying uploaded logo Date: Mon, 06 Jan 2025 17:21:44 +0100 Message-ID: <20250106162144.20480-1-adolf.belka@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6435727499126730320==" List-Id: --===============6435727499126730320== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable - Something changed in some package in CU188 that means that the existing met= hod of printing the content type to the browser no longer worked. - I tested it in some stand alone code and even if using text/txt for the con= tent-type print statement the File::Copy::copy then resulted in an Internal Server E= rror with the same message as with the image file which was "malformed header from s= cript 'logo.cgi': Bad header:". - I tested it with text, html, image and application. In all cases the error = message about a bad header was provided. - Did some searching and found an alternative way to explicitly print the hea= der info which is what I have used in this patch change. - With this approach, in the stand alone code, I was able to get an image, ht= ml code or text shown in the browser correctly and without any error message. - I then used this new method in the logo.cgi code as submitted here and test= ed the change in my vm testbed and the image was shown in the captive portal corr= ectly. - So this change fixes the problem with the logo not being shown but I have b= een unable to identify what changed to stop the method that worked prior to CU188 fro= m working any more. Fixes: Bug13795 Tested-by: Adolf Belka Signed-off-by: Adolf Belka --- html/cgi-bin/captive/logo.cgi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/captive/logo.cgi b/html/cgi-bin/captive/logo.cgi index 8f292b171..09fe784b8 100644 --- a/html/cgi-bin/captive/logo.cgi +++ b/html/cgi-bin/captive/logo.cgi @@ -2,9 +2,9 @@ ############################################################################= ### # = # # IPFire.org - A linux based firewall = # -# Copyright (C) 2016 Alexander Marx alexander.marx(a)ipfire.org = # +# Copyright (C) 2016-2024 IPFire Team = # # = # -# This program is free software you can redistribute it and/or modify = # +# This program is free software: you can redistribute it and/or modify = # # it under the terms of the GNU General Public License as published by = # # the Free Software Foundation, either version 3 of the License, or = # # (at your option) any later version. = # @@ -29,6 +29,7 @@ use File::Copy; =20 require '/var/ipfire/general-functions.pl'; =20 +my $q =3D new CGI; my $logo =3D "${General::swroot}/captive/logo.dat"; =20 # Send 404 if logo was not uploaded and exit @@ -37,8 +38,8 @@ if (!-e $logo) { exit(0); } =20 -print "Content-Type: application/octet-stream\n\n"; - # Send image data +print $q->header(-type=3D>"image/jpeg"); +binmode STDOUT; File::Copy::copy $logo, \*STDOUT; exit(0); --=20 2.47.1 --===============6435727499126730320==--