WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #30300


Ignore:
Timestamp:
11/09/2014 06:04:54 PM (7 years ago)
Author:
TobiasBg
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30300

    • Property Keywords has-patch added
    • Property Summary changed from setUserSetting js function only removes first unwanted charter to setUserSetting js function only removes first unwanted character
  • Ticket #30300 – Description

    initial v1  
    1 The function comments of the function setUserSetting in `wp-includes/js/utils.js` says the following: "Both name and value must be only ASCII letters, numbers or underscore (...)". The function removes the unwanted charters with the js `replace` function, in the current code, it only removes the first occurrence of an unwanted charter. This is solved by adding the `g` modifier to the replace regex. See the attached patch.
     1The function comments of the function setUserSetting in `wp-includes/js/utils.js` says the following: "Both name and value must be only ASCII letters, numbers or underscore (...)". The function removes the unwanted characters with the js `replace` function, in the current code, it only removes the first occurrence of an unwanted character. This is solved by adding the `g` modifier to the replace regex. See the attached patch.
    22
    33How to reproduce:
    44* Open your browsers console while you are logged in to your WordPress installation.
    5 * Run the following command: `setUserSetting('test--', 'bad-value-')` (note that the - charter is not allowed)
     5* Run the following command: `setUserSetting('test--', 'bad-value-')` (note that the - character is not allowed)
    66* The console will return `"test-"` (not `"test"` as expected).
    77* Run `getUserSetting('test-')`.