summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Murphy <sgmurphy@gmail.com>2009-02-09 17:29:27 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-02-17 09:43:13 -0500
commit75ebd45ebdcf26849e47d3c11a2cc2aa6e946c01 (patch)
treeb95fbe85b6d7ba759eaf108393c062776e7f8294
parented964ea980be63999860aaa5f39274768eca5d59 (diff)
Fixed #1170: Auto-linking bug when URL cotains special chars.
-rw-r--r--lib/util.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php
index 7ce4e229e..5204693bc 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -412,8 +412,8 @@ function common_replace_urls_callback($text, $callback) {
// Then clean up what the regex left behind
$offset = 0;
- foreach($matches[0] as $url) {
- $url = htmlspecialchars_decode($url);
+ foreach($matches[0] as $orig_url) {
+ $url = htmlspecialchars_decode($orig_url);
// Make sure we didn't pick up an email address
if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue;
@@ -456,6 +456,9 @@ function common_replace_urls_callback($text, $callback) {
if (!in_array($url_parts[2], $tlds)) continue;
+ // Put the url back the way we found it.
+ $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url);
+
// Call user specified func
$modified_url = $callback($url);