summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-03-01 15:00:33 -0800
committerZach Copley <zach@status.net>2010-03-01 15:00:33 -0800
commit1b1dab206fa1ff99ae40867cda6fa48857f5c1c0 (patch)
tree0504f7c060de6bbacb3a81f4225146a6c73e399a /lib
parent3c4ead4996fe910ac800d4940f429910faf1bb8b (diff)
parentbb94f160bd19e82babd5224cd39ff01ad2bd0380 (diff)
Merge branch 'testing' into 0.9.x
* testing: Upgrade XML output scrubbing to better deal with newline and a few other chars
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php
index c7cb4f313..c1fc64a5a 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -802,8 +802,28 @@ function common_shorten_links($text)
function common_xml_safe_str($str)
{
- // Neutralize control codes and surrogates
- return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
+ // 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);
}
function common_tag_link($tag)