Ticket #16943: 16943.patch
File 16943.patch, 5.8 KB (added by , 14 years ago) |
---|
-
wp-includes/formatting.php
### Eclipse Workspace Patch 1.0 #P wordpress-trunk
1245 1245 if ( is_array($value) ) { 1246 1246 $value = array_map('stripslashes_deep', $value); 1247 1247 } elseif ( is_object($value) ) { 1248 $vars = get_object_vars( $value ); 1249 foreach ($vars as $key=>$data) { 1250 $value->{$key} = stripslashes_deep( $data ); 1248 foreach ( $value as &$data ) { 1249 $data = stripslashes_deep( $data ); 1251 1250 } 1252 1251 } else { 1253 1252 $value = stripslashes($value); … … 1268 1267 * @return array|string $value The encoded array (or string from the callback). 1269 1268 */ 1270 1269 function urlencode_deep($value) { 1271 $value = is_array($value) ? array_map('urlencode_deep', $value) :urlencode($value);1270 is_array( $value ) ? array_walk_recursive( $value, 'urlencode_ref' ) : $value = urlencode($value); 1272 1271 return $value; 1273 1272 } 1274 1273 1275 1274 /** 1275 * map urlencode() onto a reference 1276 * 1277 * @since 3.2 1278 * @param string $value to be urlencoded 1279 */ 1280 function urlencode_ref( &$value ) { 1281 $value = urlencode( $value ); 1282 } 1283 1284 /** 1276 1285 * Converts email addresses characters to HTML entities to block spam bots. 1277 1286 * 1278 1287 * @since 0.71 -
wp-includes/functions.php
1377 1377 * using this function. You can also retrieve the full URL with query data. 1378 1378 * 1379 1379 * Adding a single key & value or an associative array. Setting a key value to 1380 * emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER1381 * value.1380 * an empty string removes the key. Omitting oldquery_or_uri uses the 1381 * $_SERVER['REQUEST_URI'] value. 1382 1382 * 1383 1383 * @since 1.5.0 1384 1384 * 1385 * @param mixed$param1 Either newkey or an associative_array1386 * @param mixed $param2 Either newvalue or oldquery or uri1387 * @param mixed$param3 Optional. Old query or uri1385 * @param array|string $param1 Either newkey or an associative_array 1386 * @param string $param2 Either newvalue or Optional. Old query or uri 1387 * @param string $param3 Optional. Old query or uri 1388 1388 * @return string New URL query string. 1389 1389 */ 1390 1390 function add_query_arg() { 1391 $ret = ''; 1392 if ( is_array( func_get_arg(0) ) ) { 1393 if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) ) 1394 $uri = $_SERVER['REQUEST_URI']; 1395 else 1396 $uri = @func_get_arg( 1 ); 1397 } else { 1398 if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) ) 1399 $uri = $_SERVER['REQUEST_URI']; 1400 else 1401 $uri = @func_get_arg( 2 ); 1391 $args = func_get_args(); 1392 $args = array_merge( $args , array_fill( 0, 3, false )); # all unset parameter are false 1393 1394 // if first param is not an array, it forms together with the second parameter 1395 // the key=value pair. Every other argument shifts one to front then. 1396 if ( ! is_array( $args[0] ) ) { 1397 $key = array_shift( $args ); 1398 $args[0] = array( $key => $args[0] ); 1402 1399 } 1403 1400 1404 if ( $frag = strstr( $uri, '#' ) ) 1405 $uri = substr( $uri, 0, -strlen( $frag ) ); 1406 else 1407 $frag = ''; 1401 // the last argument is either query or uri, default is $_SERVER['REQUEST_URI'] 1402 $uri = false === $args[1] ? $_SERVER['REQUEST_URI'] : $args[1]; 1408 1403 1409 if ( preg_match( '|^https?://|i', $uri, $matches ) ) { 1410 $protocol = $matches[0]; 1411 $uri = substr( $uri, strlen( $protocol ) ); 1412 } else { 1413 $protocol = ''; 1414 } 1404 // pop fragment off, defaults to empty fragment 1405 if ( $fragment = (string) strstr( $uri, '#' ) ) 1406 $uri = substr( $uri, 0, -strlen( $fragment ) ); 1415 1407 1408 // shift scheme off, defaults to empty scheme 1409 if ( $scheme = (string) preg_replace( '|^(https?://)?(.*)$|i', '$1', $uri ) ) 1410 $uri = substr( $uri, strlen( $scheme ) ); 1411 1412 // extract base and query from query or uri 1416 1413 if ( strpos( $uri, '?' ) !== false ) { 1417 $parts = explode( '?', $uri, 2 ); 1418 if ( 1 == count( $parts ) ) { 1419 $base = '?'; 1420 $query = $parts[0]; 1421 } else { 1422 $base = $parts[0] . '?'; 1423 $query = $parts[1]; 1424 } 1425 } elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) { 1414 list( $base, $query ) = explode( '?', $uri, 2 ); 1415 $base .= '?'; 1416 } elseif ( $scheme || strpos( $uri, '=' ) === false ) { 1426 1417 $base = $uri . '?'; 1427 1418 $query = ''; 1428 1419 } else { … … 1432 1423 1433 1424 wp_parse_str( $query, $qs ); 1434 1425 $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string 1435 if ( is_array( func_get_arg( 0 ) ) ) { 1436 $kayvees = func_get_arg( 0 ); 1437 $qs = array_merge( $qs, $kayvees ); 1438 } else { 1439 $qs[func_get_arg( 0 )] = func_get_arg( 1 ); 1440 } 1426 $qs = array_merge( $qs, $args[0] ); 1441 1427 1442 foreach ( (array) $qs as $k => $v ) { 1443 if ( $v === false ) 1444 unset( $qs[$k] ); 1445 } 1428 // remove all entries === false 1429 if ( $del = array_keys( $qs, false, true ) ) 1430 $qs = array_diff_key( $qs, array_flip( $del ) ); 1446 1431 1447 1432 $ret = build_query( $qs ); 1448 1433 $ret = trim( $ret, '?' ); 1449 1434 $ret = preg_replace( '#=(&|$)#', '$1', $ret ); 1450 $ret = $ protocol . $base . $ret . $frag;1435 $ret = $scheme . $base . $ret . $fragment; 1451 1436 $ret = rtrim( $ret, '?' ); 1452 1437 return $ret; 1453 1438 } … … 1458 1443 * @since 1.5.0 1459 1444 * 1460 1445 * @param string|array $key Query key or keys to remove. 1461 * @param bool $query When false uses the $_SERVER value.1446 * @param bool $query Optional. When false uses the $_SERVER value. 1462 1447 * @return string New URL query string. 1463 1448 */ 1464 function remove_query_arg( $key, $query=false ) { 1465 if ( is_array( $key ) ) { // removing multiple keys 1466 foreach ( $key as $k ) 1467 $query = add_query_arg( $k, false, $query ); 1468 return $query; 1469 } 1470 return add_query_arg( $key, false, $query ); 1449 function remove_query_arg( $key, $query = false ) { 1450 $key = (array) $key; 1451 if ( $count = count( $key ) ) 1452 $key = array_combine( $key, array_fill( 0, $count, false ) ); 1453 return add_query_arg( $key, $query ); 1471 1454 } 1472 1455 1473 1456 /**