summaryrefslogtreecommitdiff
path: root/forum/utils
diff options
context:
space:
mode:
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]");