Moodle

lib/editor/htmlarea/htmlarea.php should escape strings before sending to JS

Details

  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

I am sure that the strings are all correctly escaped in the language files, and also the language editor correctly escapes when you save ,, but I just had a problem with a site that was sending "OK"-button to Javascript, and it was breaking the editor.

Since we do support local translations, and don't enforce the editor, I believe we should put some smarts into the htmlarea.php to do something like addslashes(stripslashes($string)) before sending it to JS.

Activity

Hide
Petr Škoda (skodak) added a comment -

addslashes is a nono for javascript, we have addslashes_js() for that, I am not sure here, but in this case we might have to use s() or htmlentities() too

Show
Petr Škoda (skodak) added a comment - addslashes is a nono for javascript, we have addslashes_js() for that, I am not sure here, but in this case we might have to use s() or htmlentities() too
Hide
Penny Leach added a comment -

sure, whatever the correct function is

Show
Penny Leach added a comment - sure, whatever the correct function is

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: