From 7f033deee500b8a3447cef38a5fcd98b5e2887f3 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Wed, 4 Sep 2019 16:03:56 +0000 Subject: [PATCH] Remove _convert_urlencoded_to_entities() from the get_the_content() callback. Props vortfu, whyisjake, peterwilsoncc git-svn-id: https://develop.svn.wordpress.org/trunk@45935 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-template.php | 17 ------------- .../phpunit/data/formatting/utf-8/entitize.py | 24 ------------------- .../data/formatting/utf-8/entitized.txt | 6 ----- .../data/formatting/utf-8/u-urlencode.py | 24 ------------------- .../data/formatting/utf-8/u-urlencoded.txt | 6 ----- .../tests/formatting/UrlEncodedToEntities.php | 24 ------------------- 6 files changed, 101 deletions(-) delete mode 100644 tests/phpunit/data/formatting/utf-8/entitize.py delete mode 100644 tests/phpunit/data/formatting/utf-8/entitized.txt delete mode 100644 tests/phpunit/data/formatting/utf-8/u-urlencode.py delete mode 100644 tests/phpunit/data/formatting/utf-8/u-urlencoded.txt delete mode 100644 tests/phpunit/tests/formatting/UrlEncodedToEntities.php diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index de395cebd2..ddb5180117 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -368,26 +368,9 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post = } } - if ( $preview ) { // Preview fix for JavaScript bug with foreign languages. - $output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output ); - } - return $output; } -/** - * Preview fix for JavaScript bug with foreign languages. - * - * @since 3.1.0 - * @access private - * - * @param array $match Match array from preg_replace_callback. - * @return string - */ -function _convert_urlencoded_to_entities( $match ) { - return '&#' . base_convert( $match[1], 16, 10 ) . ';'; -} - /** * Display the post excerpt. * diff --git a/tests/phpunit/data/formatting/utf-8/entitize.py b/tests/phpunit/data/formatting/utf-8/entitize.py deleted file mode 100644 index efa7cb18d5..0000000000 --- a/tests/phpunit/data/formatting/utf-8/entitize.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generates entitized.txt from utf-8.txt -# -# entitized.txt is used by Tests_Formatting_UrlEncodedToEntities - -import codecs -import sys - -def entitize(line): - """Convert text to &#[dec]; entities.""" - line = line.strip(); - line = ["&#%d;" % ord(s) for s in line] - return "".join(line) - -if __name__ == "__main__": - args = sys.argv[1:] - if args and args[0] in ("-h", "--help"): - print "Usage: python entitize.py < utf-8.txt > entitized.txt" - sys.exit(2) - - sys.stdin = codecs.getreader("utf-8")(sys.stdin) - sys.stdout = codecs.getwriter("ascii")(sys.stdout) - - lines = sys.stdin.readlines() - sys.stdout.write( "\n".join(map(entitize, lines)) ) diff --git a/tests/phpunit/data/formatting/utf-8/entitized.txt b/tests/phpunit/data/formatting/utf-8/entitized.txt deleted file mode 100644 index 93d897585f..0000000000 --- a/tests/phpunit/data/formatting/utf-8/entitized.txt +++ /dev/null @@ -1,6 +0,0 @@ -章子怡 -François Truffaut -საქართველო -Björk Guðmundsdóttir -宮崎 駿 -👍 \ No newline at end of file diff --git a/tests/phpunit/data/formatting/utf-8/u-urlencode.py b/tests/phpunit/data/formatting/utf-8/u-urlencode.py deleted file mode 100644 index c20a14f1f8..0000000000 --- a/tests/phpunit/data/formatting/utf-8/u-urlencode.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generates u-urlencoded.txt from utf-8.txt -# -# u-urlencoded.txt is used by Tests_Formatting_UrlEncodedToEntities - -import codecs -import sys - -def uurlencode(line): - """Use %u[hexvalue] percent encoding.""" - line = line.strip() - line = ["%%u%04X" % ord(s) for s in line] - return "".join(line) - -if __name__ == "__main__": - args = sys.argv[1:] - if args and args[0] in ("-h", "--help"): - print "Usage: python u-urlencode.py < utf-8.txt > u-urlencoded.txt" - sys.exit(2) - - sys.stdin = codecs.getreader("utf-8")(sys.stdin) - sys.stdout = codecs.getwriter("ascii")(sys.stdout) - - lines = sys.stdin.readlines() - sys.stdout.write( "\n".join(map(uurlencode, lines)) ) diff --git a/tests/phpunit/data/formatting/utf-8/u-urlencoded.txt b/tests/phpunit/data/formatting/utf-8/u-urlencoded.txt deleted file mode 100644 index d6f77fdc3f..0000000000 --- a/tests/phpunit/data/formatting/utf-8/u-urlencoded.txt +++ /dev/null @@ -1,6 +0,0 @@ -%u7AE0%u5B50%u6021 -%u0046%u0072%u0061%u006E%u00E7%u006F%u0069%u0073%u0020%u0054%u0072%u0075%u0066%u0066%u0061%u0075%u0074 -%u10E1%u10D0%u10E5%u10D0%u10E0%u10D7%u10D5%u10D4%u10DA%u10DD -%u0042%u006A%u00F6%u0072%u006B%u0020%u0047%u0075%u00F0%u006D%u0075%u006E%u0064%u0073%u0064%u00F3%u0074%u0074%u0069%u0072 -%u5BAE%u5D0E%u3000%u99FF -%u1F44D \ No newline at end of file diff --git a/tests/phpunit/tests/formatting/UrlEncodedToEntities.php b/tests/phpunit/tests/formatting/UrlEncodedToEntities.php deleted file mode 100644 index 3fefd420eb..0000000000 --- a/tests/phpunit/tests/formatting/UrlEncodedToEntities.php +++ /dev/null @@ -1,24 +0,0 @@ -assertEquals( $entity, preg_replace_callback( '/\%u([0-9A-F]{4,5})/', '_convert_urlencoded_to_entities', $u_urlencoded ), $entity ); - } - - function data() { - $input = file( DIR_TESTDATA . '/formatting/utf-8/u-urlencoded.txt' ); - $output = file( DIR_TESTDATA . '/formatting/utf-8/entitized.txt' ); - $data_provided = array(); - foreach ( $input as $key => $value ) { - $data_provided[] = array( trim( $value ), trim( $output[ $key ] ) ); - } - return $data_provided; - } -} -