Fix comment issue in Highlighter
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 4 Dec 2013 13:15:14 +0000 (14:15 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 4 Dec 2013 13:18:03 +0000 (14:18 +0100)
Multiline comments that have a single line comment as prefix are
parsed correctly now

wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php

index e52bda65f683f19158beb94293eef2eadfe503a0..38376437fb4888303ce5628a42b91f691691ee19 100644 (file)
@@ -197,16 +197,18 @@ abstract class Highlighter extends SingletonFactory {
                        }
                        
                        $cacheCommentsRegEx .= "(";
-                       if (!empty($this->singleLineComment)) {
-                               $cacheCommentsRegEx .= "(?:".implode('|', array_map('preg_quote', $this->singleLineComment)).")[^\n]*";
-                               if (!empty($this->commentStart)) {
+                       if (!empty($this->commentStart)) {
+                               $cacheCommentsRegEx .= '(?:'.implode('|', array_map('preg_quote', $this->commentStart)).').*?(?:'.implode('|', array_map('preg_quote', $this->commentEnd)).')';
+                               
+                               if (!empty($this->singleLineComment)) {
                                        $cacheCommentsRegEx .= '|';
                                }
                        }
                        
-                       if (!empty($this->commentStart)) {
-                               $cacheCommentsRegEx .= '(?:'.implode('|', array_map('preg_quote', $this->commentStart)).').*?(?:'.implode('|', array_map('preg_quote', $this->commentEnd)).')';
+                       if (!empty($this->singleLineComment)) {
+                               $cacheCommentsRegEx .= "(?:".implode('|', array_map('preg_quote', $this->singleLineComment)).")[^\n]*";
                        }
+                       
                        $cacheCommentsRegEx .= ")";
                        
                        $this->cacheCommentsRegEx = new Regex($cacheCommentsRegEx, Regex::DOT_ALL);