From a76f895146c14e2022a79395e82140b60b05c427 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Wed, 27 Jan 2021 23:45:29 +0000 Subject: [PATCH] Privacy: Ensure that exported user data reports can't be found with directory listings. By moving from `.html` to `.php` files, we can prevent directory listings, and ensure that WordPress can load. Fixes #52299. Props lucasbustamante, xkon, freewebmentor, SergeyBiryukov, whyisjake. git-svn-id: https://develop.svn.wordpress.org/trunk@50037 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/privacy-tools.php | 4 ++-- src/wp-includes/functions.php | 2 +- tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php | 2 +- .../tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index 629302fc2d..eb3407c06b 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -322,13 +322,13 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { } // Protect export folder from browsing. - $index_pathname = $exports_dir . 'index.html'; + $index_pathname = $exports_dir . 'index.php'; if ( ! file_exists( $index_pathname ) ) { $file = fopen( $index_pathname, 'w' ); if ( false === $file ) { wp_send_json_error( __( 'Unable to protect personal data export folder from browsing.' ) ); } - fwrite( $file, '' ); + fwrite( $file, 'expectOutputString( '' ); wp_privacy_generate_personal_data_export_file( self::$export_request_id ); - $this->assertTrue( file_exists( self::$exports_dir . 'index.html' ) ); + $this->assertTrue( file_exists( self::$exports_dir . 'index.php' ) ); } /**