From db9c95a056175676c9315b0d6b893661e10d6eb0 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 23 Feb 2021 01:58:21 +0000 Subject: [PATCH] Security: move Content-Security-Policy script loaders. Move `wp_get_script_tag()`, `wp_print_script_tag()`, `wp_print_inline_script_tag()` and `wp_get_inline_script_tag()` functions from `functions.php` to `script-loader.php`. Relocate related tests to `dependencies` sub-directory. Follow up to [50167]. Props adamsilverstein, hellofromTonya, SergeyBiryukov. Fixes #39941. git-svn-id: https://develop.svn.wordpress.org/trunk@50409 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 120 ------------------ src/wp-includes/script-loader.php | 120 ++++++++++++++++++ .../wpInlineScriptTag.php | 5 +- .../wpSanitizeScriptAttributes.php | 4 +- .../wpScriptTag.php | 9 +- 5 files changed, 135 insertions(+), 123 deletions(-) rename tests/phpunit/tests/{functions => dependencies}/wpInlineScriptTag.php (95%) rename tests/phpunit/tests/{functions => dependencies}/wpSanitizeScriptAttributes.php (97%) rename tests/phpunit/tests/{functions => dependencies}/wpScriptTag.php (94%) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 56f50ce2de..5935f781fb 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -7866,123 +7866,3 @@ function is_php_version_compatible( $required ) { function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { return abs( (float) $expected - (float) $actual ) <= $precision; } - -/** - * Sanitizes an attributes array into an attributes string to be placed inside a `\n", wp_sanitize_script_attributes( $attributes ) ); -} - -/** - * Prints formatted `\n", wp_sanitize_script_attributes( $attributes ), $javascript ); -} - -/** - * Prints inline JavaScript wrapped in `\n", wp_sanitize_script_attributes( $attributes ) ); +} + +/** + * Prints formatted `\n", wp_sanitize_script_attributes( $attributes ), $javascript ); +} + +/** + * Prints inline JavaScript wrapped in `