private static function fixBBCodes($message) {
static $quoteRegex = null;
static $quoteCallback = null;
+ static $urlRegex = null;
+ static $urlCallback = null;
static $imgRegex = null;
static $mediaRegex = null;
static $attachRegex = null;
return "[quote='".$username."','".$postLink."']";
};
+ $urlRegex = new Regex('\[url="([^"]+)"\]', Regex::CASE_INSENSITIVE);
+ $urlCallback = function ($matches) {
+ $url = str_replace(["\\", "'"], ["\\\\", "\'"], $matches[1]);
+ return "[url='".$url."']";
+ };
+
$imgRegex = new Regex('\[img width=(\d+) height=\d+\](.*?)\[/img\]');
$mediaRegex = new Regex('\[video=([a-z]+);([a-z0-9-_]+)\]', Regex::CASE_INSENSITIVE);
// quotes
$message = $quoteRegex->replace($message, $quoteCallback);
+ // url
+ $message = $urlRegex->replace($message, $urlCallback);
+
// img
$message = $imgRegex->replace($message, "[img='\\2',none,\\1][/img]");