Make WordPress Core

Changeset 33947


Ignore:
Timestamp:
09/08/2015 04:43:27 PM (11 years ago)
Author:
wonderboymusic
Message:

After [33840], JS regex needs the g modifier.

Add another unit test case.

Props kitchin.
Fixes #22781.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/utils.js

    r33840 r33947  
    162162                secure = !! userSettings.secure;
    163163
    164         name = name.toString().replace( /[^A-Za-z0-9_-]/, '' );
     164        name = name.toString().replace( /[^A-Za-z0-9_-]/g, '' );
    165165
    166166        if ( typeof value === 'number' ) {
    167167                value = parseInt( value, 10 );
    168168        } else {
    169                 value = value.toString().replace( /[^A-Za-z0-9_-]/, '' );
     169                value = value.toString().replace( /[^A-Za-z0-9_-]/g, '' );
    170170        }
    171171
  • trunk/tests/phpunit/tests/option/userSettings.php

    r33840 r33947  
    3535                $this->assertEmpty( $foo );
    3636
    37                 $this->set_user_setting( 'foo', 'foo-bar' );
     37                $this->set_user_setting( 'foo', 'foo-bar-baz' );
    3838
    39                 $this->assertEquals( 'foo-bar', get_user_setting( 'foo' ) );
     39                $this->assertEquals( 'foo-bar-baz', get_user_setting( 'foo' ) );
     40        }
     41
     42        function test_set_user_setting_strip_asterisks() {
     43                $foo = get_user_setting( 'foo' );
     44
     45                $this->assertEmpty( $foo );
     46
     47                $this->set_user_setting( 'foo', 'foo*bar*baz' );
     48
     49                $this->assertEquals( 'foobarbaz', get_user_setting( 'foo' ) );
    4050        }
    4151
Note: See TracChangeset for help on using the changeset viewer.