Línea 251... |
Línea 251... |
251 |
protected function xml_safe_text_content($content) {
|
251 |
protected function xml_safe_text_content($content) {
|
252 |
return htmlspecialchars($this->xml_safe_utf8($content), ENT_NOQUOTES);
|
252 |
return htmlspecialchars($this->xml_safe_utf8($content), ENT_NOQUOTES);
|
253 |
}
|
253 |
}
|
Línea 254... |
Línea 254... |
254 |
|
254 |
|
255 |
/**
|
255 |
/**
|
256 |
* Perform some UTF-8 cleaning, stripping the control chars (\x0-\x1f)
|
256 |
* Perform some UTF-8 cleaning, stripping the control chars (\x00-\x1f)
|
257 |
* but tabs (\x9), newlines (\xa) and returns (\xd). The delete control
|
257 |
* but tabs (\x09), newlines (\xa) and returns (\xd). The delete control
|
258 |
* char (\x7f) is also included. All them are forbiden in XML 1.0 specs.
|
258 |
* char (\x7f) is also included. All them are forbiden in XML 1.0 specs.
|
259 |
* The expression below seems to be UTF-8 safe too because it simply
|
259 |
* The expression below seems to be UTF-8 safe too because it simply
|
260 |
* ignores the rest of characters. Also normalize linefeeds and return chars.
|
260 |
* ignores the rest of characters. Also normalize linefeeds and return chars.
|
261 |
*/
|
261 |
*/
|
262 |
protected function xml_safe_utf8($content) {
|
262 |
protected function xml_safe_utf8($content) {
|
263 |
$content = preg_replace('/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is', '', $content ?? ''); // clean CTRL chars.
|
263 |
$content = core_text::trim_ctrl_chars($content ?? '');
|
264 |
$content = preg_replace("/\r\n|\r/", "\n", $content); // Normalize line&return=>line
|
264 |
$content = preg_replace("/\r\n|\r/", "\n", $content); // Normalize line&return=>line
|
265 |
return fix_utf8($content);
|
265 |
return fix_utf8($content);
|
Línea 266... |
Línea 266... |
266 |
}
|
266 |
}
|