Ticket #12416: 12416.2.diff
File 12416.2.diff, 13.2 KB (added by , 15 years ago) |
---|
-
wp-includes/theme.php
1200 1200 function get_theme_mod($name, $default = false) { 1201 1201 $theme = get_current_theme(); 1202 1202 1203 $mods = get_option( esc_sql( "mods_$theme" ));1203 $mods = get_option( "mods_$theme" ); 1204 1204 1205 1205 if ( isset($mods[$name]) ) 1206 1206 return apply_filters( "theme_mod_$name", $mods[$name] ); -
wp-includes/functions.php
307 307 * @uses apply_filters() Calls 'option_$option', after checking the option, with 308 308 * the option value. 309 309 * 310 * @param string $option Name of option to retrieve. Should already be SQL-escaped310 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. 311 311 * @return mixed Value set for the option. 312 312 */ 313 313 function get_option( $option, $default = false ) { … … 339 339 if ( false === $value ) { 340 340 if ( defined( 'WP_INSTALLING' ) ) 341 341 $suppress = $wpdb->suppress_errors(); 342 // expected_slashed ($option) 343 $row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$option' LIMIT 1" ); 342 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s' LIMIT 1", $option ) ); 344 343 if ( defined( 'WP_INSTALLING' ) ) 345 344 $wpdb->suppress_errors( $suppress ); 346 345 … … 482 481 * @uses do_action() Calls 'update_option' hook before updating the option. 483 482 * @uses do_action() Calls 'update_option_$option' and 'updated_option' hooks on success. 484 483 * 485 * @param string $option Option name. Expected to not be SQL-escaped 486 * @param mixed $newvalue Option value. 484 * @param string $option Option name. Expected to not be SQL-escaped. 485 * @param mixed $newvalue Option value. Expected to not be SQL-escaped. 487 486 * @return bool False if value was not updated and true if value was updated. 488 487 */ 489 488 function update_option( $option, $newvalue ) { … … 491 490 492 491 wp_protect_special_option( $option ); 493 492 494 $safe_option = esc_sql( $option );495 493 $newvalue = sanitize_option( $option, $newvalue ); 496 $oldvalue = get_option( $ safe_option );494 $oldvalue = get_option( $option ); 497 495 $newvalue = apply_filters( 'pre_update_option_' . $option, $newvalue, $oldvalue ); 498 496 499 497 // If the new and old values are the same, no need to update. … … 516 514 if ( ! defined( 'WP_INSTALLING' ) ) { 517 515 $alloptions = wp_load_alloptions(); 518 516 if ( isset( $alloptions[$option] ) ) { 519 $alloptions[$option] = $ newvalue;520 wp_cache_set( 'alloptions', $ alloptions, 'options' );517 $alloptions[$option] = $_newvalue; 518 wp_cache_set( 'alloptions', $_alloptions, 'options' ); 521 519 } else { 522 wp_cache_set( $option, $ newvalue, 'options' );520 wp_cache_set( $option, $_newvalue, 'options' ); 523 521 } 524 522 } 525 523 … … 554 552 * @uses do_action() Calls 'add_option' hook before adding the option. 555 553 * @uses do_action() Calls 'add_option_$option' and 'added_option' hooks on success. 556 554 * 557 * @param string $option Name of option to add. Expect s to NOT be SQLescaped.558 * @param mixed $value Optional. Option value, can be anything. 555 * @param string $option Name of option to add. Expected to not be SQL-escaped. 556 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. 559 557 * @param mixed $deprecated Optional. Description. Not used anymore. 560 558 * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up. 561 559 * @return null returns when finished. … … 567 565 global $wpdb; 568 566 569 567 wp_protect_special_option( $option ); 570 $safe_option = esc_sql( $option );571 568 $value = sanitize_option( $option, $value ); 572 569 573 570 // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query 574 571 $notoptions = wp_cache_get( 'notoptions', 'options' ); 575 572 if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) 576 if ( false !== get_option( $ safe_option ) )573 if ( false !== get_option( $option ) ) 577 574 return; 578 575 579 576 $_value = $value; … … 617 614 * @uses do_action() Calls 'delete_option' hook before option is deleted. 618 615 * @uses do_action() Calls 'deleted_option' and 'delete_option_$option' hooks on success. 619 616 * 620 * @param string $option Name of option to remove. 617 * @param string $option Name of option to remove. Expected to not be SQL-escaped. 621 618 * @return bool True, if option is successfully deleted. False on failure. 622 619 */ 623 620 function delete_option( $option ) { … … 626 623 wp_protect_special_option( $option ); 627 624 628 625 // Get the ID, if no ID then return 629 // expected_slashed ($option) 630 $row = $wpdb->get_row( "SELECT autoload FROM $wpdb->options WHERE option_name = '$option'" ); 626 $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = '%s'", $option ) ); 631 627 if ( is_null( $row ) ) 632 628 return false; 633 629 do_action( 'delete_option', $option ); 634 // expected_slashed ($option) 635 $result = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name = '$option'" ); 630 $result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = '%s'", $option) ); 636 631 if ( ! defined( 'WP_INSTALLING' ) ) { 637 632 if ( 'yes' == $row->autoload ) { 638 633 $alloptions = wp_load_alloptions(); … … 662 657 * @uses do_action() Calls 'delete_transient_$transient' hook before transient is deleted. 663 658 * @uses do_action() Calls 'deleted_transient' hook on success. 664 659 * 665 * @param string $transient Transient name. Expected to not be SQL-escaped 660 * @param string $transient Transient name. Expected to not be SQL-escaped. 666 661 * @return bool true if successful, false otherwise 667 662 */ 668 663 function delete_transient( $transient ) { … … 673 668 if ( $_wp_using_ext_object_cache ) { 674 669 $result = wp_cache_delete( $transient, 'transient' ); 675 670 } else { 676 $option = '_transient_' . esc_sql( $transient );671 $option = '_transient_' . $transient; 677 672 $result = delete_option( $option ); 678 673 } 679 674 … … 711 706 if ( $_wp_using_ext_object_cache ) { 712 707 $value = wp_cache_get( $transient, 'transient' ); 713 708 } else { 714 $safe_transient = esc_sql( $transient ); 715 $transient_option = '_transient_' . $safe_transient; 709 $transient_option = '_transient_' . $transient; 716 710 if ( ! defined( 'WP_INSTALLING' ) ) { 717 711 // If option is not in alloptions, it is not autoloaded and thus has a timeout 718 712 $alloptions = wp_load_alloptions(); 719 713 if ( !isset( $alloptions[$transient_option] ) ) { 720 $transient_timeout = '_transient_timeout_' . $ safe_transient;714 $transient_timeout = '_transient_timeout_' . $transient; 721 715 if ( get_option( $transient_timeout ) < time() ) { 722 716 delete_option( $transient_option ); 723 717 delete_option( $transient_timeout ); … … 746 740 * transient value to be stored. 747 741 * @uses do_action() Calls 'set_transient_$transient' and 'setted_transient' hooks on success. 748 742 * 749 * @param string $transient Transient name. Expected to not be SQL-escaped 750 * @param mixed $value Transient value. 743 * @param string $transient Transient name. Expected to not be SQL-escaped. 744 * @param mixed $value Transient value. Expected to not be SQL-escaped. 751 745 * @param int $expiration Time until expiration in seconds, default 0 752 746 * @return bool False if value was not set and true if value was set. 753 747 */ … … 761 755 } else { 762 756 $transient_timeout = '_transient_timeout_' . $transient; 763 757 $transient = '_transient_' . $transient; 764 $safe_transient = esc_sql( $transient ); 765 if ( false === get_option( $safe_transient ) ) { 758 if ( false === get_option( $transient ) ) { 766 759 $autoload = 'yes'; 767 760 if ( $expiration ) { 768 761 $autoload = 'no'; … … 1000 993 * @return mixed A scalar data 1001 994 */ 1002 995 function maybe_serialize( $data ) { 1003 if ( is_array( $data ) || is_object( $data ) )996 if ( !is_scalar( $data ) ) 1004 997 return serialize( $data ); 1005 998 1006 if ( is_serialized( $data ) )1007 return serialize( $data );1008 1009 999 return $data; 1010 1000 } 1011 1001 … … 3384 3374 * @uses apply_filters() Calls 'site_option_$option', after checking the option, with 3385 3375 * the option value. 3386 3376 * 3387 * @param string $option Name of option to retrieve. Should already be SQL-escaped3377 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. 3388 3378 * @param mixed $default Optional value to return if option doesn't exist. Default false. 3389 3379 * @param bool $use_cache Whether to use cache. Multisite only. Default true. 3390 3380 * @return mixed Value set for the option. … … 3431 3421 * option value to be stored. 3432 3422 * @uses do_action() Calls 'add_site_option_$option' and 'add_site_option' hooks on success. 3433 3423 * 3434 * @param string $option Name of option to add. Expect s to not be SQLescaped.3435 * @param mixed $value Optional. Option value, can be anything. 3424 * @param string $option Name of option to add. Expected to not be SQL-escaped. 3425 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. 3436 3426 * @return bool False if option was not added and true if option was added. 3437 3427 */ 3438 3428 function add_site_option( $option, $value ) { … … 3475 3465 * @uses do_action() Calls 'delete_site_option' and 'delete_site_option_$option' 3476 3466 * hooks on success. 3477 3467 * 3478 * @param string $option Name of option to remove. Expected to be SQL-escaped.3468 * @param string $option Name of option to remove. Expected to not be SQL-escaped. 3479 3469 * @return bool True, if succeed. False, if failure. 3480 3470 */ 3481 3471 function delete_site_option( $option ) { … … 3517 3507 * option value to be stored. 3518 3508 * @uses do_action() Calls 'update_site_option_$option' and 'update_site_option' hooks on success. 3519 3509 * 3520 * @param string $option Name of option. Expected to not be SQL-escaped 3521 * @param mixed $value Option value. 3510 * @param string $option Name of option. Expected to not be SQL-escaped. 3511 * @param mixed $value Option value. Expected to not be SQL-escaped. 3522 3512 * @return bool False if value was not updated and true if value was updated. 3523 3513 */ 3524 3514 function update_site_option( $option, $value ) { … … 3564 3554 * @uses do_action() Calls 'delete_site_transient_$transient' hook before transient is deleted. 3565 3555 * @uses do_action() Calls 'deleted_site_transient' hook on success. 3566 3556 * 3567 * @param string $transient Transient name. Expected to not be SQL-escaped 3557 * @param string $transient Transient name. Expected to not be SQL-escaped. 3568 3558 * @return bool True if successful, false otherwise 3569 3559 */ 3570 3560 function delete_site_transient( $transient ) { … … 3574 3564 if ( $_wp_using_ext_object_cache ) { 3575 3565 $result = wp_cache_delete( $transient, 'site-transient' ); 3576 3566 } else { 3577 $option = '_site_transient_' . esc_sql( $transient );3567 $option = '_site_transient_' . $transient; 3578 3568 $result = delete_site_option( $option ); 3579 3569 } 3580 3570 if ( $result ) … … 3599 3589 * @uses apply_filters() Calls 'site_transient_$option' hook, after checking the transient, with 3600 3590 * the transient value. 3601 3591 * 3602 * @param string $transient Transient name. Expected to not be SQL-escaped 3592 * @param string $transient Transient name. Expected to not be SQL-escaped. 3603 3593 * @return mixed Value of transient 3604 3594 */ 3605 3595 function get_site_transient( $transient ) { … … 3614 3604 } else { 3615 3605 // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. 3616 3606 $no_timeout = array('update_core', 'update_plugins', 'update_themes'); 3617 $transient_option = '_site_transient_' . esc_sql( $transient );3607 $transient_option = '_site_transient_' . $transient; 3618 3608 if ( ! in_array( $transient, $no_timeout ) ) { 3619 $transient_timeout = '_site_transient_timeout_' . esc_sql( $transient );3609 $transient_timeout = '_site_transient_timeout_' . $transient; 3620 3610 $timeout = get_site_option( $transient_timeout ); 3621 3611 if ( false !== $timeout && $timeout < time() ) { 3622 3612 delete_site_option( $transient_option ); … … 3646 3636 * transient value to be stored. 3647 3637 * @uses do_action() Calls 'set_site_transient_$transient' and 'setted_site_transient' hooks on success. 3648 3638 * 3649 * @param string $transient Transient name. Expected to not be SQL-escaped 3650 * @param mixed $value Transient value. 3639 * @param string $transient Transient name. Expected to not be SQL-escaped. 3640 * @param mixed $value Transient value. Expected to not be SQL-escaped. 3651 3641 * @param int $expiration Time until expiration in seconds, default 0 3652 3642 * @return bool False if value was not set and true if value was set. 3653 3643 */ … … 3661 3651 } else { 3662 3652 $transient_timeout = '_site_transient_timeout_' . $transient; 3663 3653 $transient = '_site_transient_' . $transient; 3664 $safe_transient = esc_sql( $transient ); 3665 if ( false === get_site_option( $safe_transient ) ) { 3654 if ( false === get_site_option( $transient ) ) { 3666 3655 if ( $expiration ) 3667 3656 add_site_option( $transient_timeout, time() + $expiration ); 3668 3657 $result = add_site_option( $transient, $value ); -
wp-includes/formatting.php
2441 2441 2442 2442 case 'siteurl': 2443 2443 case 'home': 2444 $value = stripslashes($value); 2445 $value = esc_url($value); 2444 $value = esc_url_raw($value); 2446 2445 break; 2447 2446 default : 2448 2447 $value = apply_filters("sanitize_option_{$option}", $value, $option);