Remove _convert_urlencoded_to_entities() from the get_the_content() callback.
Merges [45937] to the 4.7 branch. Props vortfu, whyisjake, peterwilsoncc git-svn-id: https://develop.svn.wordpress.org/branches/4.7@45954 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8fcbf67732
commit
707096e9e0
@ -324,25 +324,9 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) {
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -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)) )
|
@ -1,6 +0,0 @@
|
||||
章子怡
|
||||
François Truffaut
|
||||
საქართველო
|
||||
Björk Guðmundsdóttir
|
||||
宮崎 駿
|
||||
👍
|
@ -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)) )
|
@ -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
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_UrlEncodedToEntities extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
function test_convert_urlencoded_to_entities( $u_urlencoded, $entity ) {
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user