summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormio <stigma@disroot.org>2025-04-16 19:33:53 +1000
committermio <stigma@disroot.org>2025-05-08 15:31:35 +1000
commit80ca7b28a3ac73635d0c11df832bd973f4708ce6 (patch)
tree93ab85c5fbc558dab9051328f942fa9702c32e4d
parent194a97c77a92ae7bed4b4def3506dcd5d95cff6a (diff)
downloadtdeutils-80ca7b28.tar.gz
tdeutils-80ca7b28.zip
ark: Fix unzip v6 date parsing
unzip v6 changed the date format from MM-DD-YY to YYYY-MM-DD. Fixes: https://bugs.trinitydesktop.org/show_bug.cgi?id=3207 Signed-off-by: mio <stigma@disroot.org> (cherry picked from commit 3a179b33ef4299990486901782802a626bb68b88)
-rw-r--r--ark/zip.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/ark/zip.cpp b/ark/zip.cpp
index f8b5281..6d4db01 100644
--- a/ark/zip.cpp
+++ b/ark/zip.cpp
@@ -34,6 +34,7 @@
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kprocess.h>
+#include <kprocio.h>
#include <kpassdlg.h>
// ark includes
@@ -50,18 +51,66 @@ ZipArch::ZipArch( ArkWidget *_gui, const TQString & _fileName )
verifyCompressUtilityIsAvailable( m_archiver_program );
verifyUncompressUtilityIsAvailable( m_unarchiver_program );
+ // Compatibility with unzip v5 and v6.
+ // - unzip 5 prints dates as MM-DD-YY.
+ // - unzip 6 prints dates as YYYY-MM-DD.
+ // Presume version 6 as it was released in 2009.
+ bool unzipV5 = false;
+ if (m_bUnarchUtilityIsAvailable)
+ {
+ KProcIO proc;
+ proc << m_unarchiver_program;
+ proc << "-v";
+ if (proc.start(KProcIO::Block))
+ {
+ proc.wait();
+ if (proc.normalExit() && proc.exitStatus() == 0)
+ {
+ TQString line;
+ proc.readln(line);
+ auto parts = TQStringList::split(' ', line);
+ unzipV5 = (parts.size() >= 2) && (parts[1][0] == '5');
+ }
+ }
+ }
+
m_headerString = "----";
- m_repairYear = 9; m_fixMonth = 7; m_fixDay = 8; m_fixTime = 10;
+ m_fixTime = 10;
m_dateCol = 5;
m_numCols = 7;
+ if (unzipV5)
+ {
+ kdDebug(1601) << "ZipArch: unzip v5 detected." << endl;
+ m_repairYear = 9;
+ m_fixMonth = 7;
+ m_fixDay = 8;
+ }
+ else
+ {
+ m_fixYear = 7;
+ m_fixMonth = 8;
+ m_fixDay = 9;
+ }
+
m_archCols.append( new ArchColumns( 1, TQRegExp( "[0-9]+" ) ) );
m_archCols.append( new ArchColumns( 2, TQRegExp( "[^\\s]+" ) ) );
m_archCols.append( new ArchColumns( 3, TQRegExp( "[0-9]+" ) ) );
m_archCols.append( new ArchColumns( 4, TQRegExp( "[0-9.]+%" ) ) );
- m_archCols.append( new ArchColumns( 7, TQRegExp( "[01][0-9]" ), 2 ) );
- m_archCols.append( new ArchColumns( 8, TQRegExp( "[0-3][0-9]" ), 2 ) );
- m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-9][0-9]" ), 2 ) );
+
+ if (unzipV5)
+ {
+ m_archCols.append( new ArchColumns( 7, TQRegExp( "[01][0-9]" ), 2 ) );
+ m_archCols.append( new ArchColumns( 8, TQRegExp( "[0-3][0-9]" ), 2 ) );
+ m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-9][0-9]" ), 2 ) );
+ }
+ else
+ {
+ m_archCols.append( new ArchColumns( 7, TQRegExp( "[0-9]{4}" ), 4 ) );
+ m_archCols.append( new ArchColumns( 8, TQRegExp( "[01][0-9]" ), 2 ) );
+ m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-3][0-9]" ), 2 ) );
+ }
+
m_archCols.append( new ArchColumns( 10, TQRegExp( "[0-9:]+" ), 6 ) );
m_archCols.append( new ArchColumns( 6, TQRegExp( "[a-fA-F0-9]+ {2}" ) ) );
m_archCols.append( new ArchColumns( 0, TQRegExp( "[^\\n]+" ), 4096 ) );