X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/ae288f251dc7521badc3647cb5c3c8d9639b7fee..cc9044a1aa3f79cda743040573d49bc71fb7805f:/upload.inc.php
diff --git a/upload.inc.php b/upload.inc.php
index e70f573..0ee432b 100644
--- a/upload.inc.php
+++ b/upload.inc.php
@@ -51,10 +51,16 @@ function messagehtml($input)
if ($User->admin and preg_match('/\A<[a-z][^>]*>/', $input)) {
return $input; # allow html input as is if privileged
}
- $html = preg_replace(
- ["/\r?\n/", "'(?:
\n?){2}'"],
- ["
\n", "
"],
- htmlspecialchars($input)
- );
+ $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 + '/_(? '$1', # italic + '/\*(? '$1', # bold + ]; + $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); return "
$html
"; }