summaryrefslogtreecommitdiff
path: root/forum/utils
diff options
context:
space:
mode:
authordeva <deva>2008-10-28 12:34:44 +0000
committerdeva <deva>2008-10-28 12:34:44 +0000
commit5ccf183b325e899685e4ac6ded56e3c1dd7a26c9 (patch)
tree01d879c4e872202a48f9603b112687b322570d73 /forum/utils
parent9559ea4fc6f7758c5252fb5cee1b5fa5315da94a (diff)
Fixed annoying bug on url/image parsing.
Diffstat (limited to 'forum/utils')
-rw-r--r--forum/utils/parser.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/forum/utils/parser.php b/forum/utils/parser.php
index f79be2a..e4a164e 100644
--- a/forum/utils/parser.php
+++ b/forum/utils/parser.php
@@ -10,6 +10,8 @@ include_once($UTIL_DIR . "/smileys.php");
// error_reporting
//
+// http://www1.cs.columbia.edu/~lennox/perlre.html
+
function parse($input, $indent = "")
{
global $testing;
@@ -39,20 +41,20 @@ function parse($input, $indent = "")
while(strpos($output, $imgendmarker)) $imgendmarker .= $imgendsymbol;
// Find and mark image URLs (so that they don't get converted into normal <a/> links)
- $output = preg_replace("/http:\/\/(.*?\.jpg|.*?\.gif|.*?\.png|.*?\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output);
+ $output = preg_replace("/http:\/\/(\S*?\.jpg|\S*?\.gif|\S*?\.png|\S*?\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output);
- // Replace URLs with <a></a> tags
- $output = preg_replace("/http:\/\/(.*?)([\n ]|$)/s", "<a href=\"http://$1\">$1</a>$2", $output);
+ // Replace URLs with <a></a> tags
+ $output = preg_replace("/http:\/\/(\S*?)([\n ]|$)/s", "<a href=\"http://$1\">$1</a>$2", $output);
// Convert marked images to img tags and links
- $output = preg_replace("/".$imgstartmarker."(.*?)".$imgendmarker."/s", "<a href=\"http://$1\"><img alt=\"$1\" src=\"?mode=imagecache&amp;uri=http://$1\"/></a>", $output);
+ $output = preg_replace("/".$imgstartmarker."(\S*?)".$imgendmarker."/s", "<a href=\"http://$1\"><img alt=\"$1\" src=\"?mode=imagecache&amp;uri=http://$1\"/></a>", $output);
- // Replace URLs with <a></a> tags
+ // Replace file links with their thumbnails.
$output = preg_replace("/\{\{([0-9]*?)\}\}/s", "<a href=\"?mode=file&amp;fid=$1\"><img src=\"?mode=file&amp;preview=1&amp;fid=$1\"/></a>", $output);
- // Replace [quote title=...]...[/quote]
+ // Replace [quote title=...]...[/quote]
$urls = "";
- while(($start = strpos($output, "[quote"))) {
+ while(($start = strpos($output, "[quote"))) {
$pre = substr($output, 0, $start);
$url = substr($output, $start);
$end = strpos($url, "[/quote]") + strlen("[/quote]");