X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/df953b78c421e60f37832fa4581e5d3ca2a1bd8d..f8527c143033f51fecd929789ef7ad6589c8c2b4:/upload.inc.php diff --git a/upload.inc.php b/upload.inc.php index 7810ff6..86af604 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/", "/\n/"], - ["\n", "
", "

\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/" => "

\n

", # newlines start paragraphs + '/\b_(\w+)_\b/' => '$1', # italic + '/\b\*(\w+)\*\b/' => '$1', # bold + ]; + $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); return "

$html

"; }