Due to one potential bug in PHP under Win32 (http://bugs.php.net/37775)

the [[cntrl]] pcre class was breaking some chars. Changed to a safer
alternative. Bug 5777.
(http://moodle.org/bugs/bug.php?op=show&bugid=5777)

Merged from MOODLE_16_STABLE
This commit is contained in:
stronk7
2006-06-10 23:33:49 +00:00
parent c0bd060a58
commit 5dd95d35e5
+3 -2
View File
@@ -460,10 +460,11 @@
function xml_tag_safe_content($content) {
global $CFG;
//If enabled, we strip all the control chars from the text but tabs, newlines and returns
//If enabled, we strip all the control chars (\x0-\x1f) from the text but tabs (\x9),
//newlines (\xa) and returns (\xd). The delete control char (\x7f) is also included.
//because they are forbiden in XML 1.0 specs. The expression below seems to be
//UTF-8 safe too because it simply ignores the rest of characters.
$content = preg_replace("/(?(?=[[:cntrl:]])[^\n\r\t])/is","",$content);
$content = preg_replace("/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is","",$content);
if (!empty($CFG->unicodedb)) {
// Don't perform the conversion. Contents are Unicode.
$content = preg_replace("/\r\n|\r/", "\n", htmlspecialchars($content));