From cebf7f02499460521bbd93bf27456a2f8fd423f0 Mon Sep 17 00:00:00 2001 From: Jerome B Date: Wed, 28 Sep 2022 10:45:35 +0200 Subject: [PATCH 1/3] move space in $title to prevent double space between id and href --- src/wp-includes/class-wp-styles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index b318d0fc17149..24f1ab1454f1f 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -224,10 +224,10 @@ public function do_item( $handle, $group = false ) { } $rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; - $title = isset( $obj->extra['title'] ) ? sprintf( "title='%s'", esc_attr( $obj->extra['title'] ) ) : ''; + $title = isset( $obj->extra['title'] ) ? sprintf( "title='%s' ", esc_attr( $obj->extra['title'] ) ) : ''; $tag = sprintf( - "\n", + "\n", $rel, $handle, $title, From 71eb9bffbd6aaf653cefd80fc9e3cb53de51e318 Mon Sep 17 00:00:00 2001 From: Jerome B Date: Wed, 28 Sep 2022 11:19:39 +0200 Subject: [PATCH 2/3] tests : remove double space before href in expected link tag --- tests/phpunit/tests/dependencies/styles.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 8e7721d1e91f3..34a9847f2f4d8 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -63,10 +63,10 @@ public function test_wp_enqueue_style() { wp_enqueue_style( 'no-deps-null-version-print-media', 'example.com', array(), null, 'print' ); $ver = get_bloginfo( 'version' ); - $expected = "\n"; - $expected .= "\n"; - $expected .= "\n"; - $expected .= "\n"; + $expected = "\n"; + $expected .= "\n"; + $expected .= "\n"; + $expected .= "\n"; $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); @@ -86,7 +86,7 @@ public function test_wp_enqueue_style_with_html5_support_does_not_contain_type_a wp_enqueue_style( 'no-deps-no-version', 'example.com' ); $ver = get_bloginfo( 'version' ); - $expected = "\n"; + $expected = "\n"; $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } @@ -107,24 +107,24 @@ public function test_protocols() { // Try with an HTTP reference. wp_enqueue_style( 'reset-css-http', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); - $expected .= "\n"; + $expected .= "\n"; // Try with an HTTPS reference. wp_enqueue_style( 'reset-css-https', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); - $expected .= "\n"; + $expected .= "\n"; // Try with an automatic protocol reference (//). wp_enqueue_style( 'reset-css-doubleslash', '//yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); - $expected .= "\n"; + $expected .= "\n"; // Try with a local resource and an automatic protocol reference (//). $url = '//my_plugin/style.css'; wp_enqueue_style( 'plugin-style', $url ); - $expected .= "\n"; + $expected .= "\n"; // Try with a bad protocol. wp_enqueue_style( 'reset-css-ftp', 'ftp://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); - $expected .= "\n"; + $expected .= "\n"; // Go! $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); @@ -147,7 +147,7 @@ public function test_inline_styles() { $style .= "\tbackground: red;\n"; $style .= '}'; - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; @@ -176,7 +176,7 @@ public function test_inline_styles_concat() { $style .= "\tbackground: red;\n"; $style .= '}'; - $expected = "\n"; + $expected = "\n"; $expected .= "\n"; @@ -258,7 +258,7 @@ public function test_multiple_inline_styles() { $style2 .= "\tbackground: blue;\n"; $style2 .= '}'; - $expected = "\n"; + $expected = "\n"; $expected .= "'; - $expected = "\n"; + $expected = "\n"; $expected .= "$style\n"; wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); @@ -305,7 +305,7 @@ public function test_plugin_doing_inline_styles_wrong() { */ public function test_unnecessary_style_tags() { - $expected = "\n"; + $expected = "\n"; wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); @@ -320,7 +320,7 @@ public function test_unnecessary_style_tags() { public function test_conditional_inline_styles_are_also_conditional() { $expected = << - + @@ -350,8 +350,8 @@ public function test_wp_register_style() { public function test_wp_add_inline_style_for_handle_without_source() { $style = 'a { color: blue; }'; - $expected = "\n"; - $expected .= "\n"; + $expected = "\n"; + $expected .= "\n"; $expected .= "\n"; From cefe713d7edefe11322f41a82aefb4b44c68fc13 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 28 Sep 2022 12:47:19 +0300 Subject: [PATCH 3/3] Reorder the spaces a bit; adjust the RTL tag too --- src/wp-includes/class-wp-styles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 24f1ab1454f1f..b14ad7cbefb5f 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -224,10 +224,10 @@ public function do_item( $handle, $group = false ) { } $rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; - $title = isset( $obj->extra['title'] ) ? sprintf( "title='%s' ", esc_attr( $obj->extra['title'] ) ) : ''; + $title = isset( $obj->extra['title'] ) ? sprintf( " title='%s'", esc_attr( $obj->extra['title'] ) ) : ''; $tag = sprintf( - "\n", + "\n", $rel, $handle, $title, @@ -259,7 +259,7 @@ public function do_item( $handle, $group = false ) { } $rtl_tag = sprintf( - "\n", + "\n", $rel, $handle, $title,