Skip to content

Commit

Permalink
Merge branch 'wip-MDL-30358-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
Damyon Wiese committed Oct 27, 2014
2 parents 42b6b39 + bf8542c commit 2b97417
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ function validate($value, $options = null) {
}
$stripvalues = array(
'#</?(?!img|canvas|hr).*?>#im', // all tags except img, canvas and hr
'#(\xc2|\xa0|\s|&nbsp;)#', //any whitespaces actually
'#(\xc2\xa0|\s|&nbsp;)#', // Any whitespaces actually.
);
if (!empty($CFG->strictformsrequired)) {
$value = preg_replace($stripvalues, '', (string)$value);
Expand Down
4 changes: 4 additions & 0 deletions lib/tests/formslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function test_require_rule() {
$this->assertTrue($rule->validate("Something\nmore"));
$this->assertTrue($rule->validate("\nmore"));
$this->assertTrue($rule->validate(" more "));
$this->assertTrue($rule->validate('ш'));
$this->assertTrue($rule->validate(""));
$this->assertTrue($rule->validate("0"));
$this->assertTrue($rule->validate(0));
$this->assertTrue($rule->validate(true));
Expand Down Expand Up @@ -88,6 +90,8 @@ public function test_require_rule() {
$this->assertTrue($rule->validate("\nmore"));
$this->assertTrue($rule->validate(" more "));
$this->assertTrue($rule->validate("0"));
$this->assertTrue($rule->validate('ш'));
$this->assertTrue($rule->validate(""));
$this->assertTrue($rule->validate(0));
$this->assertTrue($rule->validate(true));
$this->assertTrue($rule->validate('<p>x</p>'));
Expand Down

0 comments on commit 2b97417

Please sign in to comment.