Upgrade XML output scrubbing to better deal with newline and a few other chars
This commit is contained in:
parent
04c4facba9
commit
a5dc5f9c62
22
lib/util.php
22
lib/util.php
@ -809,7 +809,27 @@ function common_shorten_links($text)
|
|||||||
|
|
||||||
function common_xml_safe_str($str)
|
function common_xml_safe_str($str)
|
||||||
{
|
{
|
||||||
// Neutralize control codes and surrogates
|
// Replace common eol and extra whitespace input chars
|
||||||
|
$unWelcome = array(
|
||||||
|
"\t", // tab
|
||||||
|
"\n", // newline
|
||||||
|
"\r", // cr
|
||||||
|
"\0", // null byte eos
|
||||||
|
"\x0B" // vertical tab
|
||||||
|
);
|
||||||
|
|
||||||
|
$replacement = array(
|
||||||
|
' ', // single space
|
||||||
|
' ',
|
||||||
|
'', // nothing
|
||||||
|
'',
|
||||||
|
' '
|
||||||
|
);
|
||||||
|
|
||||||
|
$str = str_replace($unWelcome, $replacement, $str);
|
||||||
|
|
||||||
|
// Neutralize any additional control codes and UTF-16 surrogates
|
||||||
|
// (Twitter uses '*')
|
||||||
return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
|
return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user