X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/04a1a7a24edbf8423a48f51609d545a5a7a3eb42..58c5ec6b45dcc52107f5e7c8bbca2933c7f2e98d:/upload.inc.php
diff --git a/upload.inc.php b/upload.inc.php
index d7d572d..e270b76 100644
--- a/upload.inc.php
+++ b/upload.inc.php
@@ -48,16 +48,22 @@ function messagehtml($input)
if (empty($input)) {
return;
}
- if ($User->admin and preg_match('/\A<[a-z][^>]*>/', $input)) {
+ if ($User and $User->admin and preg_match('/\A<[a-z][^>]*>/', $input)) {
return $input; # allow html input as is if privileged
}
$markup = [
+ '{<((?:\w+:|/).+?)>}' => '<$1>', # unescape link entities
+ '{<(?:https?://)?([^>\s|]+)>}' => '<$1 $1>', # unnamed link
+ '{<([^>\s|]+)[\s|]([^>]+)>}' => '$2', # hyperlink
"/\r\n?/" => "\n", # unix newlines
"/ +\n/" => "
", # trailing spaces for hard line break
- "/\n/" => "
", # newlines start paragraphs - '/\b_(\w+)_\b/' => '$1', # italic - '/\b\*(\w+)\*\b/' => '$1', # bold + "/^[-*] (.*)$\n?/m" => '
$1
\n", # paragraph + "{^(
$1
', # monospace
];
- $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input));
- return "$html
"; + return preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); }