Opened 9 years ago
Last modified 4 years ago
#30300 new defect (bug)
setUserSetting js function only removes first unwanted character
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.7 |
Component: | Administration | Keywords: | has-patch dev-feedback |
Focuses: | javascript | Cc: |
Description (last modified by )
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.
How to reproduce:
- Open your browsers console while you are logged in to your WordPress installation.
- Run the following command:
setUserSetting('test--', 'bad-value-')
(note that the - character is not allowed) - The console will return
"test-"
(not"test"
as expected). - Run
getUserSetting('test-')
. - The console returns
"badvalue-"
(not"badvalue"
as expected). - You may want to delete the setting by executing
deleteUserSetting('test-')
.
Attachments (1)
Change History (4)
#1
@
9 years ago
- Description modified (diff)
- Keywords has-patch added
- Summary changed from setUserSetting js function only removes first unwanted charter to setUserSetting js function only removes first unwanted character
Note: See
TracTickets for help on using
tickets.
Replace regex with the
g
modifier