Changeset 53044
- Timestamp:
- 04/01/2022 03:38:55 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r53035 r53044 821 821 * 822 822 * @since 3.7.0 823 * @since 6.0.0 Fixes support for HTML entities (Trac 30580). 823 824 * 824 825 * @param string $content Content to extract URLs from. … … 834 835 . '\([\w\d]+\)|' 835 836 . '(?:' 836 . "[^`!()\[\]{} ;:'\".,<>«»“”‘’\s]|"837 . "[^`!()\[\]{}:'\".,<>«»“”‘’\s]|" 837 838 . '(?:[:]\d+)?/?' 838 839 . ')+' … … 843 844 ); 844 845 845 $post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) ); 846 $post_links = array_unique( 847 array_map( 848 static function( $link ) { 849 // Decode to replace valid entities, like &. 850 $link = html_entity_decode( $link ); 851 // Maintain backward compatibility by removing extraneous semi-colons (`;`). 852 return str_replace( ';', '', $link ); 853 }, 854 $post_links[2] 855 ) 856 ); 846 857 847 858 return array_values( $post_links ); -
trunk/tests/phpunit/tests/functions.php
r52932 r53044 991 991 'http://www.woo.com/video?v=exvUH2qKLTU', 992 992 'http://taco.com?burrito=enchilada#guac', 993 'http://example.org/?post_type=post&p=4', 994 'http://example.org/?post_type=post&p=5', 995 'http://example.org/?post_type=post&p=6', 996 'http://typo-in-query.org/?foo=bar&baz=missing_semicolon', 993 997 ); 994 998 … … 1053 1057 1054 1058 http://taco.com?burrito=enchilada#guac 1059 1060 http://example.org/?post_type=post&p=4 1061 http://example.org/?post_type=post&p=5 1062 http://example.org/?post_type=post&p=6 1063 1064 http://typo-in-query.org/?foo=bar&baz=missing_semicolon 1055 1065 '; 1056 1066 … … 1095 1105 $this->assertCount( 8, $urls ); 1096 1106 $this->assertSame( array_slice( $original_urls, 0, 8 ), $urls ); 1107 } 1108 1109 /** 1110 * Tests for backward compatibility of `wp_extract_urls` to remove unused semicolons. 1111 * 1112 * @ticket 30580 1113 * 1114 * @covers ::wp_extract_urls 1115 */ 1116 public function test_wp_extract_urls_remove_semicolon() { 1117 $expected = array( 1118 'http://typo.com', 1119 'http://example.org/?post_type=post&p=8', 1120 ); 1121 $actual = wp_extract_urls( 1122 ' 1123 http://typo.com; 1124 http://example.org/?post_type=;p;o;s;t;&p=8; 1125 ' 1126 ); 1127 1128 $this->assertSame( $expected, $actual ); 1097 1129 } 1098 1130
Note: See TracChangeset
for help on using the changeset viewer.