summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-01 16:59:40 -0800
committerBrion Vibber <brion@pobox.com>2010-03-01 16:59:40 -0800
commit3c0729786de07b25cba4c62d71079d6b96f71994 (patch)
tree5e27620994df88cc8ac6fe15c1f71cf603425253
parente30af99873ceda83bb4e9a2e221da894e8363489 (diff)
parent0ca7aa68d3e6f86d9b5388fd33baee7b2719f5d9 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
-rw-r--r--lib/util.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php
index d12a7920d..7a170a5f5 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -809,8 +809,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)