`wp_extract_urls()` needs to also grab URLs with query strings and hashes.
Updates unit test. Props hauvong, dlh. Fixes #29314. git-svn-id: https://develop.svn.wordpress.org/trunk@29756 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
32c1d55d1f
commit
f00f28cce0
|
@ -457,23 +457,23 @@ function xmlrpc_removepostdata( $content ) {
|
||||||
*/
|
*/
|
||||||
function wp_extract_urls( $content ) {
|
function wp_extract_urls( $content ) {
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
"#("
|
"#([\"']?)("
|
||||||
. "(?:([\w-]+:)?//?)"
|
. "(?:([\w-]+:)?//?)"
|
||||||
. "[^\s()<>]+"
|
. "[^\s()<>]+"
|
||||||
. "[.]"
|
. "[.]"
|
||||||
. "(?:"
|
. "(?:"
|
||||||
. "\([\w\d]+\)|"
|
. "\([\w\d]+\)|"
|
||||||
. "(?:"
|
. "(?:"
|
||||||
. "[^`!()\[\]{};:'\".,<>?«»“”‘’\s]|"
|
. "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|"
|
||||||
. "(?:[:]\d+)?/?"
|
. "(?:[:]\d+)?/?"
|
||||||
. ")+"
|
. ")+"
|
||||||
. ")"
|
. ")"
|
||||||
. ")#",
|
. ")\\1#",
|
||||||
$content,
|
$content,
|
||||||
$post_links
|
$post_links
|
||||||
);
|
);
|
||||||
|
|
||||||
$post_links = array_unique( array_map( 'html_entity_decode', $post_links[0] ) );
|
$post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
|
||||||
|
|
||||||
return array_values( $post_links );
|
return array_values( $post_links );
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,9 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||||
'http://türkiye.icom.museum',
|
'http://türkiye.icom.museum',
|
||||||
'http://украина.icom.museum',
|
'http://украина.icom.museum',
|
||||||
'http://việtnam.icom.museum',
|
'http://việtnam.icom.museum',
|
||||||
'ftp://127.0.0.1/'
|
'ftp://127.0.0.1/',
|
||||||
|
'http://www.woo.com/video?v=exvUH2qKLTU',
|
||||||
|
'http://taco.com?burrito=enchilada#guac'
|
||||||
);
|
);
|
||||||
|
|
||||||
$blob ="
|
$blob ="
|
||||||
|
@ -481,6 +483,9 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||||
http://украина.icom.museum
|
http://украина.icom.museum
|
||||||
http://việtnam.icom.museum
|
http://việtnam.icom.museum
|
||||||
ftp://127.0.0.1/
|
ftp://127.0.0.1/
|
||||||
|
http://www.woo.com/video?v=exvUH2qKLTU
|
||||||
|
|
||||||
|
http://taco.com?burrito=enchilada#guac
|
||||||
";
|
";
|
||||||
|
|
||||||
$urls = wp_extract_urls( $blob );
|
$urls = wp_extract_urls( $blob );
|
||||||
|
|
Loading…
Reference in New Issue