Ticket #3622: 3622-Ticket-3622-extfs-uzip-fix-date-parsing.patch

File 3622-Ticket-3622-extfs-uzip-fix-date-parsing.patch, 2.5 KB (added by mooffie, 3 years ago)
  • src/vfs/extfs/helpers/uzip.in

    From 39c8d0a4f27841bf61de1d8a7a7a5b5ffce4419e Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Thu, 17 Mar 2016 17:34:45 +0200
    Subject: [PATCH] Ticket #3622: extfs/uzip: fix date parsing.
    
    By default, on Unix systems, unzip gets compiled with MDY date order. Debian
    based distros compile it with YMD order, for which this patch adds support.
    ---
     src/vfs/extfs/helpers/uzip.in | 17 ++++++++++++-----
     1 file changed, 12 insertions(+), 5 deletions(-)
    
    diff --git a/src/vfs/extfs/helpers/uzip.in b/src/vfs/extfs/helpers/uzip.in
    index b8959d7..b1c4f90 100644
    a b my $cmd_delete = "$app_zip -d"; 
    3535my $cmd_extract = "$app_unzip -p"; 
    3636 
    3737# -rw-r--r--  2.2 unx     2891 tx     1435 defN 20000330.211927 ./edit.html 
    38 # (perm) (?) (?) (size) (?) (zippedsize) (method) (yyyy)(mm)(dd)(HH)(MM) (fname) 
     38# (perm) (?) (?) (size) (?) (zippedsize) (method) (yyyy)(mm)(dd).(HH)(MM)(SS) (fname) 
    3939my $regex_zipinfo_line = qr"^(\S{7,10})\s+(\d+\.\d+)\s+(\S+)\s+(\d+)\s+(\S\S)\s+(\d+)\s+(\S{4})\s+(\d{4})(\d\d)(\d\d)\.(\d\d)(\d\d)(\d\d)\s(.*)$"; 
    4040 
    4141#     2891  Defl:N     1435  50%  03-30-00 21:19  50cbaaf8  ./edit.html 
    42 # (size) (method) (zippedsize) (zipratio) (mm)(dd)(yy|yyyy)(HH)(MM) (cksum) (fname) 
    43 my $regex_nonzipinfo_line = qr"^\s*(\d+)\s+(\S+)\s+(\d+)\s+(-?\d+\%)\s+(\d?\d)-(\d?\d)-(\d+)\s+(\d?\d):(\d\d)\s+([0-9a-f]+)\s\s(.*)$"; 
     42# (size) (method) (zippedsize) (zipratio) (mm)-(dd)-(yy|yyyy) (HH):(MM) (cksum) (fname) 
     43#                                       or: (yyyy)-(mm)-(dd) 
     44my $regex_nonzipinfo_line = qr"^\s*(\d+)\s+(\S+)\s+(\d+)\s+(-?\d+\%)\s+(\d+)-(\d?\d)-(\d+)\s+(\d?\d):(\d\d)\s+([0-9a-f]+)\s\s(.*)$"; 
    4445 
    4546# 
    4647# Main code 
    sub mczipfs_list { 
    261262                        chomp; 
    262263                        my @match = /$regex_nonzipinfo_line/; 
    263264                        next if ($#match != 10); 
     265 
     266                        # Massage the date. 
     267                        my ($year, $month, $day) = $match[4] > 12 
     268                                                     ? ($match[4], $match[5], $match[6])   # 4,5,6 = Y,M,D 
     269                                                     : ($match[6], $match[4], $match[5]);  # 4,5,6 = M,D,Y 
     270                        $year += ($year < 70 ? 2000 : 1900) if $year < 100;  # Fix 2-digit year. 
     271 
    264272                        my @rmatch = ('', '', 'unknown', $match[0], '', $match[2], $match[1], 
    265                                         $match[6] > 100 ? $match[6] : $match[6] + ($match[6] < 70 ? 2000 : 1900), $match[4], $match[5], 
    266                                         $match[7], $match[8], "00", $match[10]); 
     273                                        $year, $month, $day, $match[7], $match[8], "00", $match[10]); 
    267274                        &checked_print_file(@rmatch); 
    268275                } 
    269276        }