Changeset 61590
- Timestamp:
- 02/04/2026 06:51:51 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/wp-includes/class-wp-query.php (modified) (3 diffs)
-
src/wp-includes/deprecated.php (modified) (2 diffs)
-
src/wp-includes/formatting.php (modified) (1 diff)
-
tests/phpunit/tests/formatting/wpSlash.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r61470 r61590 2387 2387 2388 2388 if ( ! empty( $query_vars['author'] ) && '0' != $query_vars['author'] ) { 2389 $query_vars['author'] = addslashes_gpc( '' . urldecode( $query_vars['author'] ) );2389 $query_vars['author'] = wp_slash( '' . urldecode( $query_vars['author'] ) ); 2390 2390 $authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $query_vars['author'] ) ) ); 2391 2391 sort( $authors ); … … 2506 2506 if ( is_array( $query_vars['orderby'] ) ) { 2507 2507 foreach ( $query_vars['orderby'] as $_orderby => $order ) { 2508 $orderby = addslashes_gpc( urldecode( $_orderby ) );2508 $orderby = wp_slash( urldecode( $_orderby ) ); 2509 2509 $parsed = $this->parse_orderby( $orderby ); 2510 2510 … … 2519 2519 } else { 2520 2520 $query_vars['orderby'] = urldecode( $query_vars['orderby'] ); 2521 $query_vars['orderby'] = addslashes_gpc( $query_vars['orderby'] );2521 $query_vars['orderby'] = wp_slash( $query_vars['orderby'] ); 2522 2522 2523 2523 foreach ( explode( ' ', $query_vars['orderby'] ) as $i => $orderby ) { -
trunk/src/wp-includes/deprecated.php
r61518 r61590 6482 6482 6483 6483 /** 6484 * Adds slashes to a string or recursively adds slashes to strings within an array. 6485 * 6486 * This function is just a wrapper for `wp_slash()`. It was originally related to 6487 * magic quotes functionality which was deprecated in PHP 5.3.0 and removed in PHP 5.4.0. 6488 * 6489 * @since 0.71 6490 * @deprecated 7.0.0 Use wp_slash() instead. 6491 * @see wp_slash() 6492 * 6493 * @param string|array $gpc String or array of data to slash. 6494 * @return string|array Slashed `$gpc`. 6495 */ 6496 function addslashes_gpc( $gpc ) { 6497 _deprecated_function( __FUNCTION__, '7.0.0', 'wp_slash()' ); 6498 return wp_slash( $gpc ); 6499 } 6500 6501 /** 6484 6502 * Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag. 6485 6503 * … … 6509 6527 return $attributes_string; 6510 6528 } 6511 -
trunk/src/wp-includes/formatting.php
r61504 r61590 2839 2839 2840 2840 /** 2841 * Adds slashes to a string or recursively adds slashes to strings within an array.2842 *2843 * @since 0.712844 *2845 * @param string|array $gpc String or array of data to slash.2846 * @return string|array Slashed `$gpc`.2847 */2848 function addslashes_gpc( $gpc ) {2849 return wp_slash( $gpc );2850 }2851 2852 /**2853 2841 * Navigates through an array, object, or scalar, and removes slashes from the values. 2854 2842 * -
trunk/tests/phpunit/tests/formatting/wpSlash.php
r56547 r61590 102 102 $this->assertSame( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed. 103 103 } 104 105 /** 106 * Tests that addslashes_gpc() returns the same result as wp_slash() for strings. 107 * 108 * @ticket 64539 109 * @covers ::addslashes_gpc 110 * @expectedDeprecated addslashes_gpc 111 */ 112 public function test_addslashes_gpc_matches_wp_slash_for_strings() { 113 $input = "String with 'quotes' and \"double quotes\""; 114 $this->assertSame( wp_slash( $input ), addslashes_gpc( $input ) ); 115 } 116 117 /** 118 * Tests that addslashes_gpc() returns the same result as wp_slash() for arrays. 119 * 120 * @ticket 64539 121 * @covers ::addslashes_gpc 122 * @expectedDeprecated addslashes_gpc 123 */ 124 public function test_addslashes_gpc_matches_wp_slash_for_arrays() { 125 $input = array( 126 'field1' => "Value with 'apostrophe'", 127 'field2' => 'Value with "quotes"', 128 'field3' => 'user@example.com', 129 'nested' => array( 130 'key1' => 'Nested value with \\ backslash', 131 'key2' => array( 'deeply', 'nested', 'array' ), 132 ), 133 ); 134 135 $this->assertSame( wp_slash( $input ), addslashes_gpc( $input ) ); 136 } 104 137 }
Note: See TracChangeset
for help on using the changeset viewer.