Changes between Initial Version and Version 1 of Ticket #30300
- Timestamp:
- 11/09/2014 06:04:54 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30300
- Property Keywords has-patch added
-
Property
Summary
changed from
setUserSetting js function only removes first unwanted charter
tosetUserSetting 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 char ters 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.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 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. 2 2 3 3 How to reproduce: 4 4 * 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 - char ter is not allowed)5 * Run the following command: `setUserSetting('test--', 'bad-value-')` (note that the - character is not allowed) 6 6 * The console will return `"test-"` (not `"test"` as expected). 7 7 * Run `getUserSetting('test-')`.