aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/input.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-28 22:28:03 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-28 22:28:03 +0000
commit91a97937f785f013d6304478c1e4df88691c1193 (patch)
treec10fe0919573c2bee69115001a1dd154e25dad83 /engine/lib/input.php
parentecc56d64af60e120d58f148dce46a1b1b1b039cc (diff)
downloadelgg-91a97937f785f013d6304478c1e4df88691c1193.tar.gz
elgg-91a97937f785f013d6304478c1e4df88691c1193.tar.bz2
Closes #665: Using a bit of preg callback magic to do <wbr> encoding and href encoding in one pass.
git-svn-id: https://code.elgg.org/elgg/trunk@3002 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/input.php')
-rw-r--r--engine/lib/input.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/engine/lib/input.php b/engine/lib/input.php
index 80329462e..dd0480d9f 100644
--- a/engine/lib/input.php
+++ b/engine/lib/input.php
@@ -107,6 +107,7 @@
return $path;
}
+
/**
* Takes a string and turns any URLs into formatted links
@@ -115,17 +116,17 @@
* @return string The output stirng with formatted links
**/
- function parse_urls($text) {
-
- if (preg_match_all('/(?<!=["\'])((ht|f)tps?:\/\/[^\s\r\n\t<>"\'\!\(\)]+)/ie', $text, $urls)) {
-
- foreach (array_unique($urls[1]) AS $url){
- $urltext = str_replace('/', '/<wbr />', $url);
- $text = str_replace($url, '<a href="'. $url .'" style="text-decoration:underline;">'. $urltext .'</a>', $text);
- }
- }
-
- return $text;
+ function parse_urls($text) {
+
+ return preg_replace_callback('/(?<!=["\'])((ht|f)tps?:\/\/[^\s\r\n\t<>"\'\!\(\)]+)/i',
+ create_function(
+ '$matches',
+ '
+ $url = $matches[1];
+ $urltext = str_replace("/", "/<wbr />", $url);
+ return "<a href=\"$url\" style=\"text-decoration:underline;\">$urltext</a>";
+ '
+ ), $text);
}
function autop($pee, $br = 1) {