-
Bug
-
Resolution: Fixed
-
Minor
-
2.7.5, 2.8.3
-
MOODLE_27_STABLE, MOODLE_28_STABLE
-
MOODLE_27_STABLE, MOODLE_28_STABLE
-
Steps to reproduce.
- Turn on Admin -> Security -> Site policies -> Strict validation of required fields
- Set your editor to be TinyMCE
- Go and create a Multiple choice question (or anything else with a required HTML field.)
- Enter a question name.
- Type b into the Question text.
- Try to submit the form.
Actual result:
The form does not submit. Client-side JS marks the Question text as "You must supply a value here."
Expected result:
The form submits. b is not blank. (Of course the value of the field is actually '<p>b</p>'.
The problem is the regex in getValidationScript in lib/formslib.php. It is:
return array('', "
{jsVar}.replace(/(<[^img|hr|canvas]>)| |\s/ig, '') == ''");
That regex, added by MDL-28987, does not do what was intended. I will fix it.