X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/ab3ebc53acde6f060649a01403a886f5485f7bf6..dc93b0f8e382f9f449051a1b0412ed5fafebf77b:/upload.inc.php diff --git a/upload.inc.php b/upload.inc.php index aa24558..e270b76 100644 --- a/upload.inc.php +++ b/upload.inc.php @@ -1,16 +1,37 @@ 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?/m" => '
  • $1
  • ', # list item + "/^(.+)$\n?/m" => "

    $1

    \n", # paragraph + "{^

    (

  • .*
  • )(?:

    \n)?}m" => "\n", # list container + '/_(? '$1', # italic + '/\*(? '$1', # bold + '/~(? '$1', # stricken + '/`(? '$1', # monospace + ]; + return preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); +}