From b7a126d9c8bfb9d03752672b90750a23bdd9119a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 28 Apr 2017 14:29:15 +0100 Subject: [PATCH] captive: Allow uploading JPEG images, too Signed-off-by: Michael Tremer --- html/cgi-bin/captive.cgi | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/html/cgi-bin/captive.cgi b/html/cgi-bin/captive.cgi index 9851aba70d..2d2c792ad9 100755 --- a/html/cgi-bin/captive.cgi +++ b/html/cgi-bin/captive.cgi @@ -59,15 +59,15 @@ unless (-e $settingsfile) { system("touch $settingsfile"); } &Header::showhttpheaders(); -#actions -if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ +if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { my $file = $cgiparams{'logo'}; - if ($file){ - #Check if extension is png + if ($file) { + # Check if the file extension is PNG/JPEG chomp $file; + my ($name, $path, $ext) = fileparse($file, qr/\.[^.]*$/); - if ($ext ne ".png"){ - $errormessage=$Lang::tr{'Captive wrong ext'}; + if ($ext ne ".png" && $ext ne ".jpg" && $ext ne ".jpeg") { + $errormessage = $Lang::tr{'Captive wrong ext'}; } } @@ -623,20 +623,6 @@ sub validremark return 1; } -sub pngsize { - my $Buffer = shift; - my ($width,$height) = ( undef, undef ); - - if ($Buffer =~ /IHDR(.{8})/) { - my $PNG = $1; - ($width,$height) = unpack( "NN", $PNG ); - } else { - $width="invalid"; - $height= "invalid"; - }; - return ($width,$height); -} - sub error{ #if an errormessage exits, show a box with errormessage if ($errormessage) { -- 2.39.5