Have the zipfile module automatically append "/" to directory names that do

not already end with such a character. This is required for info-zip
compatibility.

FossilOrigin-Name: 94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5
This commit is contained in:
dan 2018-01-10 16:30:40 +00:00
parent e75d1f5290
commit f2ed70e4de
4 changed files with 49 additions and 15 deletions

View File

@ -1211,6 +1211,7 @@ static int zipfileUpdate(
int nData = 0; /* Size of pData buffer in bytes */
int iMethod = 0; /* Compression method for new entry */
u8 *pFree = 0; /* Free this */
char *zFree = 0; /* Also free this */
ZipfileCDS cds; /* New Central Directory Structure entry */
int bIsDir = 0;
@ -1307,6 +1308,19 @@ static int zipfileUpdate(
}
}
if( rc==SQLITE_OK && bIsDir ){
/* For a directory, check that the last character in the path is a
** '/'. This appears to be required for compatibility with info-zip
** (the unzip command on unix). It does not create directories
** otherwise. */
if( zPath[nPath-1]!='/' ){
zFree = sqlite3_mprintf("%s/", zPath);
if( zFree==0 ){ rc = SQLITE_NOMEM; }
zPath = (const char*)zFree;
nPath++;
}
}
if( rc==SQLITE_OK ){
/* Create the new CDS record. */
memset(&cds, 0, sizeof(cds));
@ -1334,6 +1348,7 @@ static int zipfileUpdate(
}
sqlite3_free(pFree);
sqlite3_free(zFree);
return rc;
}

View File

@ -1,5 +1,5 @@
C Tag\san\sunreachable\sbranch\susing\sALWAYS().
D 2018-01-10T13:58:23.623
C Have\sthe\szipfile\smodule\sautomatically\sappend\s"/"\sto\sdirectory\snames\sthat\sdo\nnot\salready\send\swith\ssuch\sa\scharacter.\sThis\sis\srequired\sfor\sinfo-zip\ncompatibility.
D 2018-01-10T16:30:40.654
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 12b6daa4bdb03fa87da27cbc205ff88ace645475b5be79414a3038b68ade14cb
@ -303,7 +303,7 @@ F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
F ext/misc/zipfile.c 92b840dc168126e192da7d6976f44b4453c40b27ad8f142a7c02dc31aaa31bd8
F ext/misc/zipfile.c 08ec2ee0093d7a91d66db4ce1d8543cc4c19fc3fb57ee113ef49f95b8613f501
F ext/rbu/rbu.c ea7d1b7eb44c123a2a619332e19fe5313500705c4a58aaa1887905c0d83ffc2e
F ext/rbu/rbu1.test 43836fac8c7179a358eaf38a8a1ef3d6e6285842
F ext/rbu/rbu10.test 1846519a438697f45e9dcb246908af81b551c29e1078d0304fae83f1fed7e9ee
@ -1598,7 +1598,7 @@ F test/wordcount.c cb589cec469a1d90add05b1f8cee75c7210338d87a5afd65260ed5c0f4bbf
F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc
F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e
F test/zipfile.test 9fb98a24f80fe0d5d09df15cd01bb290777572f45408fdfbe894f2413c9c1222
F test/zipfile.test 355e499ed4e8e0081e136510d8a7895496ee1196be10905e5dd61b0f7fdda39e
F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5
F tool/GetTclKit.bat 8995df40c4209808b31f24de0b58f90930239a234f7591e3675d45bfbb990c5d
F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91
@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 6a16f554f027ba268276b728588b5eaea837cbed85358a06a2f6da3b70e834ad
R 8ba57fadebb1bef28ae4cd97ec4b22a9
U drh
Z 3f9f5c48f04edbfb2783cc163a50a4b5
P c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7
R f9e0f45080131d91f8369d2321791b35
U dan
Z be2a3cd4c41b45eb12aa75b434fd5e7e

View File

@ -1 +1 @@
c42c734f11c58724f5d8b32cb1c92e274be350028868d6ed045b2cfd274c64e7
94bc3c60e7d2ec849b90444b06e3057ed645edf3af334f2737252960602868e5

View File

@ -91,28 +91,47 @@ do_execsql_test 2.1 {
CREATE VIRTUAL TABLE zzz USING zipfile('test.zip');
INSERT INTO zzz(name, mode) VALUES('dirname', 'drwxr-xr-x');
SELECT name, mode, data FROM zzz;
} {dirname 16877 {}}
} {dirname/ 16877 {}}
do_execsql_test 2.2 {
INSERT INTO zzz(name, data) VALUES('dirname2', NULL);
INSERT INTO zzz(name, data) VALUES('dirname2/file1.txt', 'abcdefghijklmnop');
SELECT name, mode, data FROM zzz;
} {
dirname 16877 {}
dirname2 16877 {}
dirname/ 16877 {}
dirname2/ 16877 {}
dirname2/file1.txt 33188 abcdefghijklmnop
}
do_catchsql_test 2.3 {
UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname';
UPDATE zzz SET name = 'dirname3' WHERE name = 'dirname/';
} {1 {constraint failed}}
do_execsql_test 2.4 {
SELECT name, mode, data FROM zzz;
} {
dirname 16877 {}
dirname2 16877 {}
dirname/ 16877 {}
dirname2/ 16877 {}
dirname2/file1.txt 33188 abcdefghijklmnop
}
# If on unix, check that the [unzip] utility can unpack our archive.
#
if {$::tcl_platform(platform)=="unix"} {
do_test 2.5.1 {
forcedelete dirname
forcedelete dirname2
set rc [catch { exec unzip test.zip > /dev/null } msg]
list $rc $msg
} {0 {}}
do_test 2.5.2 { file isdir dirname } 1
do_test 2.5.3 { file isdir dirname2 } 1
do_test 2.5.4 { file isdir dirname2/file1.txt } 0
do_test 2.5.5 {
set fd [open dirname2/file1.txt]
set data [read $fd]
close $fd
set data
} {abcdefghijklmnop}
}
finish_test