Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#21552 closed enhancement (fixed)

Move option sanitization in network/settings.php to sanitize_option

Reported by: wonderboymusic's profile wonderboymusic Owned by: nacin's profile nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: has-patch commit
Focuses: Cc:

Description

When Networks settings are saved in wp-admin/network/settings.php, the sanitization is done inline. This code needs to be moved to sanitize_option() where all of the other options are sanitized. This also combines duplicated code.

Attachments (2)

mu-settings-sanitize-option.diff (4.5 KB) - added by wonderboymusic 12 years ago.
sanitize-ms-options-test.diff (855 bytes) - added by wonderboymusic 12 years ago.

Download all attachments as: .zip

Change History (11)

#1 @nacin
13 years ago

  • Milestone changed from Awaiting Review to 3.5

Yes please.

#2 @nacin
12 years ago

Seems to me like in both cases, we also need to account for the value possibly being an array (someone making a change manually, rather than through settings.php).

Illegal names handling can probably be simplified to:

if ( ! is_array( $value ) )
   $value = explode( ' ', $value );
$value = array_filter( array_map( 'trim', $value ) );
if ( ! $value )
   $value = '';

Also, stripslashes() already occurs in the settings.php handler (just as it does in options.php).

#3 @nacin
12 years ago

  • Keywords needs-refresh added

#4 @wonderboymusic
12 years ago

  • Keywords needs-refresh removed

Refreshed the patch - here's a quick and dirty:

update_option( 'illegal_names', array( '', 'Woo', '' ) );
update_option( 'limited_email_domains', array(  'woo', '', 'boo.com', 'foo.net.biz..'  ) );
update_option( 'banned_email_domains', array(  'woo', '', 'boo.com', 'foo.net.biz..'  ) );

print_r( get_option( 'illegal_names' ) );
print_r( get_option( 'limited_email_domains' ) );
print_r( get_option( 'banned_email_domains' ) );
exit();

#5 @nacin
12 years ago

  • Keywords commit needs-unit-tests added

Cool stuff. Maybe that can become a unit test?

#6 @wonderboymusic
12 years ago

will fire one up fairly soon

#7 @wonderboymusic
12 years ago

Added a unit test and refreshed patch to not save filtered arrays with their original numeric indexes

#8 @nacin
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21993]:

Move sanitization for the multisite illegal_names, limited_email_domains, and banned_email_domains options to sanitize_option(). props wonderboymusic. fixes #21552.

#9 @nacin
12 years ago

  • Keywords needs-unit-tests removed
Note: See TracTickets for help on using tickets.