X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/85bd24522825b832a8f30c5629b81cf90307a388..04a1a7a24edbf8423a48f51609d545a5a7a3eb42:/upload.inc.php
diff --git a/upload.inc.php b/upload.inc.php
index 10881a2..d7d572d 100644
--- a/upload.inc.php
+++ b/upload.inc.php
@@ -51,10 +51,13 @@ 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/", '/\b_(\w+)_\b/'],
- ["\n", "
", "
", '$1' ],
- htmlspecialchars($input)
- );
+ $markup = [
+ "/\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 + ]; + $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); return "
$html
"; }