After [33840], JS regex needs the g
modifier.
Add another unit test case. Props kitchin. Fixes #22781. git-svn-id: https://develop.svn.wordpress.org/trunk@33947 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f921391922
commit
6d0c15836b
@ -161,12 +161,12 @@ function setUserSetting( name, value, _del ) {
|
||||
path = userSettings.url,
|
||||
secure = !! userSettings.secure;
|
||||
|
||||
name = name.toString().replace( /[^A-Za-z0-9_-]/, '' );
|
||||
name = name.toString().replace( /[^A-Za-z0-9_-]/g, '' );
|
||||
|
||||
if ( typeof value === 'number' ) {
|
||||
value = parseInt( value, 10 );
|
||||
} else {
|
||||
value = value.toString().replace( /[^A-Za-z0-9_-]/, '' );
|
||||
value = value.toString().replace( /[^A-Za-z0-9_-]/g, '' );
|
||||
}
|
||||
|
||||
settings = settings || {};
|
||||
|
@ -34,9 +34,19 @@ class Tests_User_Settings extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEmpty( $foo );
|
||||
|
||||
$this->set_user_setting( 'foo', 'foo-bar' );
|
||||
$this->set_user_setting( 'foo', 'foo-bar-baz' );
|
||||
|
||||
$this->assertEquals( 'foo-bar', get_user_setting( 'foo' ) );
|
||||
$this->assertEquals( 'foo-bar-baz', get_user_setting( 'foo' ) );
|
||||
}
|
||||
|
||||
function test_set_user_setting_strip_asterisks() {
|
||||
$foo = get_user_setting( 'foo' );
|
||||
|
||||
$this->assertEmpty( $foo );
|
||||
|
||||
$this->set_user_setting( 'foo', 'foo*bar*baz' );
|
||||
|
||||
$this->assertEquals( 'foobarbaz', get_user_setting( 'foo' ) );
|
||||
}
|
||||
|
||||
// set_user_setting bails if `headers_sent()` is true
|
||||
|
Loading…
Reference in New Issue
Block a user