Changeset 40661
- Timestamp:
- 05/12/2017 10:49:48 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r40256 r40661 392 392 $redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']); 393 393 394 $punctuation_pattern = implode( '|', array_map( 'preg_quote', array( 395 ' ', '%20', // space 396 '!', '%21', // exclamation mark 397 '"', '%22', // double quote 398 "'", '%27', // single quote 399 '(', '%28', // opening bracket 400 ')', '%29', // closing bracket 401 ',', '%2C', // comma 402 '.', '%2E', // period 403 ';', '%3B', // semicolon 404 '{', '%7B', // opening curly bracket 405 '}', '%7D', // closing curly bracket 406 '“', '%E2%80%9C', // opening curly quote 407 '”', '%E2%80%9D', // closing curly quote 408 ) ) ); 409 410 // Remove trailing spaces and end punctuation from the path. 411 $redirect['path'] = preg_replace( "#($punctuation_pattern)+$#", '', $redirect['path'] ); 394 // Remove trailing spaces from the path 395 $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] ); 412 396 413 397 if ( !empty( $redirect['query'] ) ) { 414 // Remove trailing spaces and end punctuation from certain terminating query string args.415 $redirect['query'] = preg_replace( "#((p|page_id|cat|tag)=[^&]*?)($punctuation_pattern)+$#", '$1', $redirect['query'] );398 // Remove trailing spaces from certain terminating query string args 399 $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); 416 400 417 401 // Clean up empty query strings -
trunk/tests/phpunit/tests/canonical/noRewrite.php
r40256 r40661 47 47 array( '/?post_type=page&page_id=1', '/?p=1' ), 48 48 49 // Trailing spaces and punctuation in query string args. 50 array( '/?p=358 ', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // space 51 array( '/?p=358%20', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded space 52 array( '/?p=358!', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // exclamation mark 53 array( '/?p=358%21', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded exclamation mark 54 array( '/?p=358"', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // double quote 55 array( '/?p=358%22', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded double quote 56 array( '/?p=358\'', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // single quote 57 array( '/?p=358%27', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded single quote 58 array( '/?p=358(', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // opening bracket 59 array( '/?p=358%28', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded opening bracket 60 array( '/?p=358)', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // closing bracket 61 array( '/?p=358%29', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded closing bracket 62 array( '/?p=358,', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // comma 63 array( '/?p=358%2C', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded comma 64 array( '/?p=358.', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // period 65 array( '/?p=358%2E', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded period 66 array( '/?p=358;', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // semicolon 67 array( '/?p=358%3B', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded semicolon 68 array( '/?p=358{', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // opening curly bracket 69 array( '/?p=358%7B', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded opening curly bracket 70 array( '/?p=358}', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // closing curly bracket 71 array( '/?p=358%7D', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded closing curly bracket 72 array( '/?p=358“', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // opening curly quote 73 array( '/?p=358%E2%80%9C', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded opening curly quote 74 array( '/?p=358”', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // closing curly quote 75 array( '/?p=358%E2%80%9D', array( 'url' => '/?p=358', 'qv' => array( 'p' => '358' ) ), 20383 ), // encoded closing curly quote 76 77 // Trailing spaces and punctuation in permalinks. 78 array( '/page/2/ ', '/page/2/', 20383 ), // space 79 array( '/page/2/%20', '/page/2/', 20383 ), // encoded space 80 array( '/page/2/!', '/page/2/', 20383 ), // exclamation mark 81 array( '/page/2/%21', '/page/2/', 20383 ), // encoded exclamation mark 82 array( '/page/2/"', '/page/2/', 20383 ), // double quote 83 array( '/page/2/%22', '/page/2/', 20383 ), // encoded double quote 84 array( '/page/2/\'', '/page/2/', 20383 ), // single quote 85 array( '/page/2/%27', '/page/2/', 20383 ), // encoded single quote 86 array( '/page/2/(', '/page/2/', 20383 ), // opening bracket 87 array( '/page/2/%28', '/page/2/', 20383 ), // encoded opening bracket 88 array( '/page/2/)', '/page/2/', 20383 ), // closing bracket 89 array( '/page/2/%29', '/page/2/', 20383 ), // encoded closing bracket 90 array( '/page/2/,', '/page/2/', 20383 ), // comma 91 array( '/page/2/%2C', '/page/2/', 20383 ), // encoded comma 92 array( '/page/2/.', '/page/2/', 20383 ), // period 93 array( '/page/2/%2E', '/page/2/', 20383 ), // encoded period 94 array( '/page/2/;', '/page/2/', 20383 ), // semicolon 95 array( '/page/2/%3B', '/page/2/', 20383 ), // encoded semicolon 96 array( '/page/2/{', '/page/2/', 20383 ), // opening curly bracket 97 array( '/page/2/%7B', '/page/2/', 20383 ), // encoded opening curly bracket 98 array( '/page/2/}', '/page/2/', 20383 ), // closing curly bracket 99 array( '/page/2/%7D', '/page/2/', 20383 ), // encoded closing curly bracket 100 array( '/page/2/“', '/page/2/', 20383 ), // opening curly quote 101 array( '/page/2/%E2%80%9C', '/page/2/', 20383 ), // encoded opening curly quote 102 array( '/page/2/”', '/page/2/', 20383 ), // closing curly quote 103 array( '/page/2/%E2%80%9D', '/page/2/', 20383 ), // encoded closing curly quote 49 array( '/?p=358 ', array('url' => '/?p=358', 'qv' => array('p' => '358') ) ), // Trailing spaces 50 array( '/?p=358%20', array('url' => '/?p=358', 'qv' => array('p' => '358') ) ), 104 51 105 52 array( '/?page_id=1', '/?p=1' ), // redirect page_id to p (should cover page_id|p|attachment_id to one another … … 108 55 array( '/?feed=rss2&p=1', '/?feed=rss2&p=1', 21841 ), 109 56 array( '/?feed=rss&p=1', '/?feed=rss2&p=1', 24623 ), 57 110 58 ); 111 59 }
Note: See TracChangeset
for help on using the changeset viewer.