Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r19850: LJSUP-9478: Admin tool for headers

Committer: gariev
LJSUP-9478: Admin tool for headers
U   trunk/cgi-bin/ljuserpics.pl
Modified: trunk/cgi-bin/ljuserpics.pl
===================================================================
--- trunk/cgi-bin/ljuserpics.pl	2011-08-25 09:58:26 UTC (rev 19849)
+++ trunk/cgi-bin/ljuserpics.pl	2011-08-25 10:29:05 UTC (rev 19850)
@@ -834,14 +834,14 @@
 
 sub format_magic {
     my $magic = shift;
-    my $hex = unpack "H*", $magic;
-    my $mime;
+    my $default = shift;
 
-    $mime = 'text/plain'; # default value
+    my $magic_ref = (ref $magic) ? $magic : \$magic;
+    my $mime = $default || 'text/plain'; # default value
     # image formats
-    $mime = 'image/jpeg' if $magic =~ /^\xff\xd8/; # JPEG
-    $mime = 'image/gif'  if $magic =~ /^GIF8/;     # GIF
-    $mime = 'image/png'  if $magic =~ /^\x89PNG/;  # PNG
+    $mime = 'image/jpeg' if $$magic_ref =~ /^\xff\xd8/; # JPEG
+    $mime = 'image/gif'  if $$magic_ref =~ /^GIF8/;     # GIF
+    $mime = 'image/png'  if $$magic_ref =~ /^\x89PNG/;  # PNG
 
     return $mime;
 }

Tags: gariev, livejournal, pl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments