Merge branch 'MDL-55650-master' of https://github.com/sammarshallou/moodle

This commit is contained in:
David Monllao
2016-08-29 14:42:55 +08:00
2 changed files with 28 additions and 4 deletions
+26
View File
@@ -86,6 +86,32 @@ class core_weblib_testcase extends advanced_testcase {
$this->assertSame('An entity: б.', s('An entity: б.'));
$this->assertSame('An entity: &.', s('An entity: &.'));
$this->assertSame('Not an entity: ৿.', s('Not an entity: ৿.'));
// Test all ASCII characters (0-127).
for ($i = 0; $i <= 127; $i++) {
$character = chr($i);
$result = s($character);
switch ($character) {
case '"' :
$this->assertSame('&quot;', $result);
break;
case '&' :
$this->assertSame('&amp;', $result);
break;
case "'" :
$this->assertSame('&#039;', $result);
break;
case '<' :
$this->assertSame('&lt;', $result);
break;
case '>' :
$this->assertSame('&gt;', $result);
break;
default:
$this->assertSame($character, $result);
break;
}
}
}
public function test_format_text_email() {
+2 -4
View File
@@ -96,10 +96,8 @@ function s($var) {
return '0';
}
// When we move to PHP 5.4 as a minimum version, change ENT_QUOTES on the
// next line to ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE, and remove the
// 'UTF-8' argument. Both bring a speed-increase.
return preg_replace('/&amp;#(\d+|x[0-9a-f]+);/i', '&#$1;', htmlspecialchars($var, ENT_QUOTES, 'UTF-8'));
return preg_replace('/&amp;#(\d+|x[0-9a-f]+);/i', '&#$1;',
htmlspecialchars($var, ENT_QUOTES | ENT_HTML401 | ENT_SUBSTITUTE));
}
/**