vB5: Fix import of double quoted URLs
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 24 Aug 2020 12:08:58 +0000 (14:08 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 24 Aug 2020 12:08:58 +0000 (14:08 +0200)
files/lib/system/exporter/VB5xExporter.class.php

index f256f29adf0245fe2c0d396cc297d1f9124c5bb5..208029667296f4f02183d7778c09c1b48d4b3d04 100644 (file)
@@ -757,6 +757,8 @@ class VB5xExporter extends AbstractExporter {
        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;
@@ -778,6 +780,12 @@ class VB5xExporter extends AbstractExporter {
                                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);
                        
@@ -828,6 +836,9 @@ class VB5xExporter extends AbstractExporter {
                // quotes
                $message = $quoteRegex->replace($message, $quoteCallback);
                
+               // url
+               $message = $urlRegex->replace($message, $urlCallback);
+               
                // img
                $message = $imgRegex->replace($message, "[img='\\2',none,\\1][/img]");