From 2af38c59afbef8b66701f578b75020519f68584a Mon Sep 17 00:00:00 2001 From: oskosk Date: Sat, 17 Feb 2018 12:36:47 -0300 Subject: [PATCH 1/2] Remove usage of create_function from markdown extra --- _inc/lib/markdown/extra.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/_inc/lib/markdown/extra.php b/_inc/lib/markdown/extra.php index 1f411dad00238..8a964381a8827 100644 --- a/_inc/lib/markdown/extra.php +++ b/_inc/lib/markdown/extra.php @@ -63,6 +63,19 @@ function Markdown($text) { return $parser->transform($text); } +/** + * Returns the length of $text loosely counting the number of UTF-8 characters with regular expression. + * Used by the Markdown_Parser class when mb_strlen is not available. + * + * @since 5.9 + * + * @return string Length of the multibyte string + * + */ +function jetpack_utf8_strlen( $text ) { + return preg_match_all( '/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/', $test, $m ); +} + # # Markdown Parser Class # @@ -1518,14 +1531,14 @@ function _detab_callback($matches) { function _initDetab() { # # Check for the availability of the function in the `utf8_strlen` property - # (initially `mb_strlen`). If the function is not available, create a - # function that will loosely count the number of UTF-8 characters with a + # (initially `mb_strlen`). If the function is not available, use jetpack_utf8_strlen + # that will loosely count the number of UTF-8 characters with a # regular expression. # - if (function_exists($this->utf8_strlen)) return; - $this->utf8_strlen = create_function('$text', 'return preg_match_all( - "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", - $text, $m);'); + if ( function_exists( $this->utf8_strlen ) ) { + return; + } + $this->utf8_strlen = 'jetpack_utf8_strlen'; } From 4660743affe13fd9b88c8455ce2c0b9c562b93ac Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Tue, 27 Feb 2018 15:53:17 +0300 Subject: [PATCH 2/2] Fixed variable name, brought double quotes back. --- _inc/lib/markdown/extra.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_inc/lib/markdown/extra.php b/_inc/lib/markdown/extra.php index 8a964381a8827..e54b4ab15821a 100644 --- a/_inc/lib/markdown/extra.php +++ b/_inc/lib/markdown/extra.php @@ -73,7 +73,7 @@ function Markdown($text) { * */ function jetpack_utf8_strlen( $text ) { - return preg_match_all( '/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/', $test, $m ); + return preg_match_all( "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", $text, $m ); } #