Really fix attachment bbcode in MyBB
authorTim Düsterhus <timwolla@googlemail.com>
Mon, 2 Dec 2013 19:36:31 +0000 (20:36 +0100)
committerTim Düsterhus <timwolla@googlemail.com>
Mon, 2 Dec 2013 19:36:31 +0000 (20:36 +0100)
files/lib/system/exporter/MyBB16xExporter.class.php

index f45d4024df57cc36a405e59958199ac22dccf76f..0e0d6ecbdec38ced81481b3bc0876d222265c24e 100644 (file)
@@ -1259,6 +1259,7 @@ class MyBB16xExporter extends AbstractExporter {
                static $videoRegex = null;
                static $quoteRegex = null;
                static $quoteCallback = null;
+               static $attachmentRegex = null;
                
                if ($videoRegex === null) {
                        $videoRegex = new Regex('\[video=[a-z]+\]');
@@ -1276,10 +1277,12 @@ class MyBB16xExporter extends AbstractExporter {
                                
                                return "[quote='".$username."','".$postLink."']";
                        });
+                       
+                       $attachmentRegex = new Regex('\[attachment=([0-9]+)\]');
                }
                
                // attachment bbcodes
-               $message = str_replace(array('[attachment=', '[/attachment]'), array('[attach=', '[/attach]'), $message);
+               $message = $attachmentRegex->replace($message, '[attach=\\1][/attach]');
                
                // code bbcodes
                $message = str_replace('[php]', '[code=php]', $message);