Merge branch 'MDL-55650-master' of https://github.com/sammarshallou/moodle
This commit is contained in:
@@ -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('"', $result);
|
||||
break;
|
||||
case '&' :
|
||||
$this->assertSame('&', $result);
|
||||
break;
|
||||
case "'" :
|
||||
$this->assertSame(''', $result);
|
||||
break;
|
||||
case '<' :
|
||||
$this->assertSame('<', $result);
|
||||
break;
|
||||
case '>' :
|
||||
$this->assertSame('>', $result);
|
||||
break;
|
||||
default:
|
||||
$this->assertSame($character, $result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_format_text_email() {
|
||||
|
||||
+2
-4
@@ -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('/&#(\d+|x[0-9a-f]+);/i', '&#$1;', htmlspecialchars($var, ENT_QUOTES, 'UTF-8'));
|
||||
return preg_replace('/&#(\d+|x[0-9a-f]+);/i', '&#$1;',
|
||||
htmlspecialchars($var, ENT_QUOTES | ENT_HTML401 | ENT_SUBSTITUTE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user