Ticket #23308: 23308.diff
| File 23308.diff, 3.3 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/formatting.php
1663 1663 $url = substr( $url, 0, strrpos( $url, ')' ) ); 1664 1664 } 1665 1665 1666 $url = esc_url($url); 1666 // After removing the unmatched parentheses suffix, 1667 // we need to re-ensure the URL does not end with punctuation. 1668 $trimmed_url = rtrim( $url, "'.,;:!?" ); // taken from the list of punctuation characters in make_clickable() 1669 $suffix = substr( $url, strlen( $trimmed_url ) ) . $suffix; 1670 1671 $url = esc_url($trimmed_url); 1667 1672 if ( empty($url) ) 1668 1673 return $matches[0]; 1669 1674 … … 1761 1766 [\\w]{1,20}+:// # Scheme and hier-part prefix 1762 1767 (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long 1763 1768 [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character 1764 (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character1765 [\'.,;:!?)] # Punctuation URL character1769 (?: # Unroll the Loop: Only allow puctuation URL characters if followed by a non-punctuation URL character 1770 [\'.,;:!?)]+ # Punctuation URL character 1766 1771 [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character 1767 1772 )* 1768 1773 ) -
tests/phpunit/tests/formatting/MakeClickable.php
389 389 href='mailto:someone@example.com'>someone@example.com</a>"; 390 390 $this->assertEquals( $html, make_clickable( $html ) ); 391 391 } 392 393 /** 394 * @ticket 23308 395 */ 396 function test_parentheses_with_trailing_extension() { 397 $urls_before = array( 398 'http://www.wordpress.org/some-(parentheses).html', 399 'foo http://www.wordpress.org/some-(parentheses).html bar', 400 ); 401 $urls_expected = array( 402 '<a href="http://www.wordpress.org/some-(parentheses).html" rel="nofollow">http://www.wordpress.org/some-(parentheses).html</a>', 403 'foo <a href="http://www.wordpress.org/some-(parentheses).html" rel="nofollow">http://www.wordpress.org/some-(parentheses).html</a> bar', 404 ); 405 foreach ($urls_before as $key => $url) { 406 $this->assertEquals( $urls_expected[$key], make_clickable( $url ) ); 407 } 408 } 409 410 /** 411 * @ticket 23308 412 */ 413 function test_github_range_urls() { 414 $urls_before = array( 415 'https://github.com/WordPress/WordPress/compare/3.9...3.9.1', 416 'foo https://github.com/WordPress/WordPress/compare/3.9...3.9.1 bar', 417 ); 418 $urls_expected = array( 419 '<a href="https://github.com/WordPress/WordPress/compare/3.9...3.9.1" rel="nofollow">https://github.com/WordPress/WordPress/compare/3.9...3.9.1</a>', 420 'foo <a href="https://github.com/WordPress/WordPress/compare/3.9...3.9.1" rel="nofollow">https://github.com/WordPress/WordPress/compare/3.9...3.9.1</a> bar', 421 ); 422 foreach ($urls_before as $key => $url) { 423 $this->assertEquals( $urls_expected[$key], make_clickable( $url ) ); 424 } 425 } 392 426 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)