diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 35b5a83942..22a3a940a6 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,7 @@ Unreleased ========== * Miscellaneous security improvements #1411 +* Follow symlinks when creating preview sites #1447 1.5.2 ===== diff --git a/cli/lib/archive.ts b/cli/lib/archive.ts index 31089ec91a..1b0548eec5 100644 --- a/cli/lib/archive.ts +++ b/cli/lib/archive.ts @@ -14,6 +14,7 @@ export async function createArchive( const output = fs.createWriteStream( archivePath ); const archive = archiver( 'zip', { zlib: { level: ZIP_COMPRESSION_LEVEL }, + followSymlinks: true, } ); output.on( 'close', () => { diff --git a/cli/lib/tests/archive.test.ts b/cli/lib/tests/archive.test.ts index bb59ac32d0..aeaac1cfd5 100644 --- a/cli/lib/tests/archive.test.ts +++ b/cli/lib/tests/archive.test.ts @@ -48,7 +48,10 @@ describe( 'Archive Module', () => { const result = await createArchive( mockSiteFolder, mockArchivePath ); expect( fs.createWriteStream ).toHaveBeenCalledWith( mockArchivePath ); - expect( archiver ).toHaveBeenCalledWith( 'zip', { zlib: { level: 9 } } ); + expect( archiver ).toHaveBeenCalledWith( 'zip', { + followSymlinks: true, + zlib: { level: 9 }, + } ); expect( mockArchiver.pipe ).toHaveBeenCalledWith( mockWriteStream ); expect( path.join ).toHaveBeenCalledWith( mockSiteFolder, 'wp-content' ); expect( mockArchiver.directory ).toHaveBeenCalledWith( diff --git a/patches/@types+archiver+6.0.2.patch b/patches/@types+archiver+6.0.2.patch new file mode 100644 index 0000000000..5a8f12dbd7 --- /dev/null +++ b/patches/@types+archiver+6.0.2.patch @@ -0,0 +1,12 @@ +diff --git a/node_modules/@types/archiver/index.d.ts b/node_modules/@types/archiver/index.d.ts +index 00829ac..fab29c9 100644 +--- a/node_modules/@types/archiver/index.d.ts ++++ b/node_modules/@types/archiver/index.d.ts +@@ -106,6 +106,7 @@ declare namespace archiver { + + interface CoreOptions { + statConcurrency?: number | undefined; ++ followSymlinks?: boolean + } + + interface TransformOptions { diff --git a/patches/archiver+6.0.1.patch b/patches/archiver+6.0.1.patch new file mode 100644 index 0000000000..16862adc83 --- /dev/null +++ b/patches/archiver+6.0.1.patch @@ -0,0 +1,22 @@ +diff --git a/node_modules/archiver/lib/core.js b/node_modules/archiver/lib/core.js +index 7c0a74d..c70117b 100644 +--- a/node_modules/archiver/lib/core.js ++++ b/node_modules/archiver/lib/core.js +@@ -631,7 +631,8 @@ Archiver.prototype.directory = function(dirpath, destpath, data) { + + var globOptions = { + stat: true, +- dot: true ++ dot: true, ++ follow: this.options.followSymlinks + }; + + function onGlobEnd() { +@@ -922,6 +923,7 @@ module.exports = Archiver; + * @global + * @property {Number} [statConcurrency=4] Sets the number of workers used to + * process the internal fs stat queue. ++ * @property {Boolean} [followSymLinks=false] Sets whether to follow symlinks. + */ + + /**