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"; |
35 | 35 | my $cmd_extract = "$app_unzip -p"; |
36 | 36 | |
37 | 37 | # -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) |
39 | 39 | my $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(.*)$"; |
40 | 40 | |
41 | 41 | # 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) |
| 44 | my $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(.*)$"; |
44 | 45 | |
45 | 46 | # |
46 | 47 | # Main code |
… |
… |
sub mczipfs_list { |
261 | 262 | chomp; |
262 | 263 | my @match = /$regex_nonzipinfo_line/; |
263 | 264 | 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 | |
264 | 272 | 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]); |
267 | 274 | &checked_print_file(@rmatch); |
268 | 275 | } |
269 | 276 | } |