From 2d7150e40df4f9c04f8cbe31f099b6619a480089 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Thu, 18 Feb 2016 20:30:54 +0000 Subject: [PATCH] Formatting: Avoid a PHP warning when `wptexturize()` is called with a trailing less-than symbol. Props westonruter. Fixes #35864. git-svn-id: https://develop.svn.wordpress.org/trunk@36578 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 2 +- tests/phpunit/tests/formatting/WPTexturize.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 89ecbbefa9..01b6405c9b 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -374,7 +374,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo */ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { // Is it an opening tag or closing tag? - if ( '/' !== $text[1] ) { + if ( isset( $text[1] ) && '/' !== $text[1] ) { $opening_tag = true; $name_offset = 1; } elseif ( 0 == count( $stack ) ) { diff --git a/tests/phpunit/tests/formatting/WPTexturize.php b/tests/phpunit/tests/formatting/WPTexturize.php index 4d7caf3d06..afd323ea79 100644 --- a/tests/phpunit/tests/formatting/WPTexturize.php +++ b/tests/phpunit/tests/formatting/WPTexturize.php @@ -2073,6 +2073,15 @@ String with a number followed by a single quote !q1!Expendables 3!q1! vestibulum return $this->assertLessThan( 200, $result ); } + /** + * Ensure that a trailing less-than symbol doesn't cause a PHP warning. + * + * @ticket 35864 + */ + function test_trailing_less_than() { + $this->assertEquals( 'F–oo<', wptexturize( 'F--oo<', true ) ); + } + function data_whole_posts() { require_once( DIR_TESTDATA . '/formatting/whole-posts.php' ); return data_whole_posts();