From: Tim Düsterhus Date: Fri, 5 Aug 2022 07:42:49 +0000 (+0200) Subject: Remove PHP-based syntax highlighters X-Git-Tag: 6.0.0_Alpha_1~1074^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ccabb1328d6f9bea2700a6aa4a005b11a8983f4b;p=GitHub%2FWoltLab%2FWCF.git Remove PHP-based syntax highlighters These are long-deprecated. If someone desires to still use them over Prism, they can grab them from the commit history. Resolves #4296 --- diff --git a/wcfsetup/install/files/lib/data/bbcode/BBCodeCache.class.php b/wcfsetup/install/files/lib/data/bbcode/BBCodeCache.class.php index d9e6c38c52..9a235c7219 100644 --- a/wcfsetup/install/files/lib/data/bbcode/BBCodeCache.class.php +++ b/wcfsetup/install/files/lib/data/bbcode/BBCodeCache.class.php @@ -22,13 +22,6 @@ class BBCodeCache extends SingletonFactory */ protected $cachedBBCodes = []; - /** - * list of known highlighters - * @var string[] - * @deprecated since 5.2, use Prism to highlight your code. - */ - protected $highlighters = []; - /** * @inheritDoc */ @@ -69,19 +62,4 @@ class BBCodeCache extends SingletonFactory { return $this->cachedBBCodes[$tag]->getAttributes(); } - - /** - * Returns a list of known highlighters. - * - * @return string[] - * @deprecated since 5.2, use Prism to highlight your code. - */ - public function getHighlighters() - { - if (empty($this->highlighters)) { - $this->highlighters = BBCodeCacheBuilder::getInstance()->getData([], 'highlighters'); - } - - return $this->highlighters; - } } diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/BashHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/BashHighlighter.class.php deleted file mode 100644 index 62ab9f704e..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/BashHighlighter.class.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class BashHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = [';', '=']; - - /** - * @inheritDoc - */ - protected $quotes = ['"', "'", '`']; - - /** - * @inheritDoc - */ - protected $singleLineComment = ['#']; - - /** - * @inheritDoc - */ - protected $commentStart = []; - - /** - * @inheritDoc - */ - protected $commentEnd = []; - - /** - * @inheritDoc - */ - protected $operators = [ - '||', - '&&', - '&', - '|', - '<<=', - '>>=', - '<<', - '+=', - '-=', - '*=', - '/=', - '%=', - '-gt', - '-lt', - '-n', - '-a', - '-o', - '+', - '-', - '*', - '/', - '%', - '<', - '?', - ':', - '==', - '!=', - '=', - '!', - '>', - '2>', - '>>', - ]; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'true', - 'false', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'if', - 'then', - 'else', - 'fi', - 'for', - 'until', - 'while', - 'do', - 'done', - 'case', - 'in', - 'esac', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - 'echo', - 'exit', - 'unset', - 'read', - '[', - ']', - 'test', - 'let', - 'sed', - 'grep', - 'awk', - ]; - - /** - * @inheritDoc - */ - protected $keywords4 = [ - '$?', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/CHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/CHighlighter.class.php deleted file mode 100644 index 851cff2dae..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/CHighlighter.class.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class CHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = ['(', ')', '{', '}', '[', ']', ';', '.', ',']; - - /** - * @inheritDoc - */ - protected $operators = [ - '=', - '>', - '<', - '!', - '~', - '?', - ':', - '==', - '<=', - '>=', - '!=', - '&&', - '||', - '++', - '--', - '+', - '-', - '*', - '/', - '&', - '|', - '^', - '%', - '<<', - '>>', - '>>>', - '+=', - '-=', - '*=', - '/=', - '&=', - '|=', - '^=', - '%=', - '<<=', - '>>=', - '>>>=', - ]; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'and', - 'and_eq', - 'asm', - 'bitand', - 'bitor', - 'break', - 'case', - 'catch', - 'compl', - 'const_cast', - 'continue', - 'default', - 'delete', - 'do', - 'dynamic_cast', - 'else', - 'for', - 'fortran', - 'friend', - 'goto', - 'if', - 'new', - 'not', - 'not_eq', - 'operator', - 'or', - 'or_eq', - 'private', - 'protected', - 'public', - 'reinterpret_cast', - 'return', - 'sizeof', - 'static_cast', - 'switch', - 'this', - 'throw', - 'try', - 'typeid', - 'using', - 'while', - 'xor', - 'xor_eq', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'auto', - 'bool', - 'char', - 'class', - 'const', - 'double', - 'enum', - 'explicit', - 'export', - 'extern', - 'float', - 'inline', - 'int', - 'long', - 'mutable', - 'namespace', - 'register', - 'short', - 'signed', - 'static', - 'struct', - 'template', - 'typedef', - 'typename', - 'union', - 'unsigned', - 'virtual', - 'void', - 'volatile', - 'wchar_t', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - '#include', - '#define', - '#if', - '#else', - '#ifdef', - '#endif', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/CssHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/CssHighlighter.class.php deleted file mode 100644 index ea3c47f3d9..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/CssHighlighter.class.php +++ /dev/null @@ -1,784 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class CssHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected function highlightNumbers($string) - { - $string = \preg_replace( - '!(?<=' . $this->separatorsRegEx . ')(-?\d*\.?\d+(?:px|pt|em|%|ex|in|cm|mm|pc)?)(?=' . $this->separatorsRegEx . ')!i', - '\\0', - $string - ); - - // highlight colors (hexadecimal numbers) - return \preg_replace( - '!(?<=' . $this->separatorsRegEx . ')(#([0-9a-f]{3}|[0-9a-f]{6}))(?=' . $this->separatorsRegEx . ')!i', - '\\0', - $string - ); - } - - /** - * @inheritDoc - */ - protected function highlightKeywords($string) - { - $string = parent::highlightKeywords($string); - - return \preg_replace( - '!(?<=' . $this->separatorsRegEx . ')(@[a-z0-9-]+)(?=' . $this->separatorsRegEx . ')!i', - '\\0', - $string - ); - } - - /** - * @inheritDoc - */ - public function highlight($string) - { - $string = \str_replace( - 'span', - '053a0024219422ca9215c0a3ed0578ee76cff477', - $string - ); // fix to not highlight the spans of the highlighter - $string = \str_replace(':link', ':li@@nk', $string); // fix to highlight pseudo-class different than tag - $string = \str_replace( - ['right:', 'left:'], - ['r@@ight:', 'l@@eft:'], - $string - ); // fix to highlight properties different than values - - $string = parent::highlight($string); - - $string = \str_replace( - ['r@@ight', 'l@@eft'], - ['right', 'left'], - $string - ); // fix to highlight properties different than values - $string = \str_replace('li@@nk', 'link', $string); // fix to highlight pseudo-class different than tag - - return \str_replace( - '053a0024219422ca9215c0a3ed0578ee76cff477', - 'span', - $string - ); // fix to not highlight the spans of the highlighter - } - - /** - * @inheritDoc - */ - protected $singleLineComment = ['//']; - - /** - * @inheritDoc - */ - protected $separators = ['(', ')', '{', '}', ';', '[', ']', ':', ',', '.']; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'align-content', - 'align-items', - 'align-self', - 'animation', - 'animation-delay', - 'animation-direction', - 'animation-duration', - 'animation-fill-mode', - 'animation-iteration-count', - 'animation-name', - 'animation-play-state', - 'animation-timing-function', - 'azimuth', - 'backface-visibility', - 'background', - 'background-attachment', - 'background-clip', - 'background-color', - 'background-image', - 'background-origin', - 'background-position', - 'background-repeat', - 'background-size', - 'border', - 'border-bottom', - 'border-bottom-color', - 'border-bottom-radius', - 'border-bottom-left-radius', - 'border-bottom-right-radius', - 'border-bottom-style', - 'border-bottom-width', - 'border-collapse', - 'border-color', - 'border-image', - 'border-image-outset', - 'border-image-repeat', - 'border-image-slice', - 'border-image-source', - 'border-image-width', - 'border-l@@eft', - 'border-left-color', - 'border-left-radius', - 'border-left-style', - 'border-left-width', - 'border-radius', - 'border-r@@ight', - 'border-right-color', - 'border-right-radius', - 'border-right-style', - 'border-right-width', - 'border-spacing', - 'border-style', - 'border-top', - 'border-top-color', - 'border-top-radius', - 'border-top-left-radius', - 'border-top-right-radius', - 'border-top-style', - 'border-top-width', - 'border-width', - 'bottom', - 'box-shadow', - 'box-sizing', - 'caption-side', - 'clear', - 'clip', - 'color', - 'column-count', - 'column-fill', - 'column-gap', - 'column-rule', - 'column-rule-color', - 'column-rule-style', - 'column-rule-width', - 'column-span', - 'column-width', - 'columns', - 'content', - 'counter-increment', - 'counter-reset', - 'cue', - 'cue-after', - 'cue-before', - 'cursor', - 'direction', - 'display', - 'elevation', - 'empty-cells', - 'flex', - 'flex-basis', - 'flex-direction', - 'flex-flow', - 'flex-grow', - 'flex-shrink', - 'flex-wrap', - 'float', - 'font', - 'font-family', - 'font-size', - 'font-size-adjust', - 'font-stretch', - 'font-style', - 'font-variant', - 'font-weight', - 'height', - 'justify-content', - 'l@@eft', - 'letter-spacing', - 'line-height', - 'list-style', - 'list-style-image', - 'list-style-position', - 'list-style-type', - 'margin', - 'margin-bottom', - 'margin-l@@eft', - 'margin-r@@ight', - 'margin-top', - 'max-height', - 'max-width', - 'min-height', - 'min-width', - 'opacity', - 'order', - 'orphans', - 'outline', - 'outline-color', - 'outline-offset', - 'outline-style', - 'outline-width', - 'overflow', - 'overflow-x', - 'overflow-y', - 'padding', - 'padding-bottom', - 'padding-l@@eft', - 'padding-r@@ight', - 'padding-top', - 'page-break-after', - 'page-break-before', - 'page-break-inside', - 'pause', - 'pause-after', - 'pause-before', - 'perspective', - 'perspective-origin', - 'pitch', - 'pitch-range', - 'play-during', - 'position', - 'quotes', - 'resize', - 'richness', - 'r@@ight', - 'scrollbar-3dlight-color', - 'scrollbar-arrow-color', - 'scrollbar-base-color', - 'scrollbar-darkshadow-color', - 'scrollbar-face-color', - 'scrollbar-highlight-color', - 'scrollbar-shadow-color', - 'scrollbar-track-color', - 'speak', - 'speak-header', - 'speak-numeral', - 'speak-punctuation', - 'speech-rate', - 'stress', - 'tab-size', - 'table-layout', - 'text-align', - 'text-align-last', - 'text-decoration', - 'text-decoration-color', - 'text-decoration-line', - 'text-decoration-style', - 'text-indent', - 'text-justify', - 'text-overflow', - 'text-shadow', - 'text-transform', - 'top', - 'transform', - 'transform-origin', - 'transform-style', - 'transition', - 'transition-delay', - 'transition-duration', - 'transition-property', - 'transition-timing-function', - 'unicode-bidi', - 'vertical-align', - 'visibility', - 'voice-family', - 'volume', - 'white-space', - 'widows', - 'width', - 'word-break', - 'word-spacing', - 'word-wrap', - 'z-index', - '!important', - '@charset', - '@font-face', - '@import', - '@keyframes', - '@media', - '@page', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'left-side', - 'far-left', - 'left', - 'center-left', - 'center-right', - 'center', - 'far-right', - 'right-side', - 'right', - 'behind', - 'leftwards', - 'rightwards', - 'inherit', - 'scroll', - 'fixed', - 'transparent', - 'none', - 'repeat-x', - 'repeat-y', - 'repeat', - 'no-repeat', - 'collapse', - 'separate', - 'auto', - 'top', - 'bottom', - 'both', - 'open-quote', - 'close-quote', - 'no-open-quote', - 'no-close-quote', - 'crosshair', - 'default', - 'pointer', - 'move', - 'e-resize', - 'ne-resize', - 'nw-resize', - 'n-resize', - 'se-resize', - 'sw-resize', - 's-resize', - 'text', - 'wait', - 'help', - 'ltr', - 'rtl', - 'inline', - 'block', - 'list-item', - 'run-in', - 'compact', - 'marker', - 'table', // table - 'inline-table', - 'table-row-group', - 'table-header-group', - 'table-footer-group', - 'table-row', - 'table-column-group', - 'table-column', - 'table-cell', - 'table-caption', - 'below', - 'level', - 'above', - 'higher', - 'lower', - 'show', - 'hide', - 'caption', // caption - 'icon', - 'menu', // menu - 'message-box', - 'small-caption', - 'status-bar', - 'normal', - 'wider', - 'narrower', - 'ultra-condensed', - 'extra-condensed', - 'condensed', - 'semi-condensed', - 'semi-expanded', - 'expanded', - 'extra-expanded', - 'ultra-expanded', - 'italic', - 'oblique', - 'small-caps', - 'bold', - 'bolder', - 'lighter', - 'inside', - 'outside', - 'disc', - 'circle', - 'square', - 'decimal', - 'decimal-leading-zero', - 'lower-roman', - 'upper-roman', - 'lower-greek', - 'lower-alpha', - 'lower-latin', - 'upper-alpha', - 'upper-latin', - 'hebrew', - 'armenian', - 'georgian', - 'cjk-ideographic', - 'hiragana', - 'katakana', - 'hiragana-iroha', - 'katakana-iroha', - 'crop', - 'cross', - 'invert', - 'visible', - 'hidden', - 'always', - 'avoid', - 'x-low', - 'low', - 'medium', - 'high', - 'x-high', - 'mix?', - 'repeat?', - 'static', - 'relative', - 'absolute', - 'portrait', - 'landscape', - 'spell-out', - 'once', - 'digits', - 'continuous', - 'code', - 'x-slow', - 'slow', - 'fast', - 'x-fast', - 'faster', - 'slower', - 'justify', - 'underline', - 'overline', - 'line-through', - 'blink', - 'capitalize', - 'uppercase', - 'lowercase', - 'embed', - 'bidi-override', - 'baseline', - 'sub', - 'super', - 'text-top', - 'middle', - 'text-bottom', - 'silent', - 'x-soft', - 'soft', - 'loud', - 'x-loud', - 'pre', - 'nowrap', - 'serif', - 'sans-serif', - 'cursive', - 'fantasy', - 'monospace', - 'empty', - 'string', - 'strict', - 'loose', - 'char', - 'true', - 'false', - 'dotted', - 'dashed', - 'solid', - 'double', - 'groove', - 'ridge', - 'inset', - 'outset', - 'larger', - 'smaller', - 'xx-small', - 'x-small', - 'small', - 'large', - 'x-large', - 'xx-large', - 'all', - 'newspaper', - 'distribute', - 'distribute-all-lines', - 'distribute-center-last', - 'inter-word', - 'inter-ideograph', - 'inter-cluster', - 'kashida', - 'ideograph-alpha', - 'ideograph-numeric', - 'ideograph-parenthesis', - 'ideograph-space', - 'keep-all', - 'break-all', - 'break-word', - 'lr-tb', - 'tb-rl', - 'thin', - 'thick', - 'inline-block', - 'w-resize', - 'hand', - 'distribute-letter', - 'distribute-space', - 'whitespace', - 'male', - 'female', - 'child', - 'print', - 'screen', - 'tty', - 'aural', - 'all', - 'braille', - 'embossed', - 'handheld', - 'projection', - 'tv', - 'hsl', - 'hsla', - 'rgb', - 'rgba', - 'flex', - 'inline-flex', - 'initial', - 'matrix', - 'matrix3d', - 'perspective', - 'rotate', - 'rotate3d', - 'rotatex', - 'rotatey', - 'rotatez', - 'scale', - 'scale3d', - 'scalex', - 'scaley', - 'scalez', - 'skew', - 'skwex', - 'skewy', - 'skewz', - 'translate', - 'translate3d', - 'translatex', - 'translatey', - 'translatez', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - 'active', - 'after', - 'any', - 'before', - 'checked', - 'default', - 'dir', - 'disabled', - 'empty', - 'enabled', - 'first', - 'first-child', - 'first-letter', - 'first-line', - 'first-of-type', - 'focus', - 'fullscreen', - 'indeterminate', - 'in-range', - 'invalid', - 'lang', - 'last-child', - 'last-of-type', - 'li@@nk', // link - 'hover', - 'not', - 'nth-child', - 'nth-last-child', - 'nth-last-of-type', - 'nth-of-type', - 'only-child', - 'only-of-type', - 'optional', - 'out-of-range', - 'read-only', - 'read-write', - 'root', - 'scope', - 'target', - 'valid', - 'visited', - ]; - - /** - * @inheritDoc - */ - protected $keywords4 = [ - 'abbr', - 'acronym', - 'address', - 'area', - 'article', - 'aside', - 'audio', - 'a', - 'base', - 'bdi', - 'bdo', - 'big', - 'blockquote', - 'body', - 'br', - 'button', - 'b', - 'canvas', - 'caption', - 'cite', - 'code', - 'col', - 'colgroup', - 'command', - 'datalist', - 'dd', - 'del', - 'details', - 'dfn', - 'div', - 'dl', - 'dt', - 'embed', - 'em', - 'fieldset', - 'figcaption', - 'figure', - 'footer', - 'form', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'head', - 'header', - 'hgroup', - 'hr', - 'html', - 'iframe', - 'img', - 'input', - 'ins', - 'i', - 'kbd', - 'keygen', - 'label', - 'legend', - 'li', - 'link', - 'map', - 'mark', - 'menu', - 'meta', - 'meter', - 'nav', - 'noscript', - 'object', - 'ol', - 'optgroup', - 'option', - 'output', - 'param', - 'pre', - 'progress', - 'p', - 'q', - 'rbc', - 'rb', - 'rp', - 'rtc', - 'rt', - 'ruby', - 'samp', - 'script', - 'section', - 'select', - 'small', - 'source', - '053a0024219422ca9215c0a3ed0578ee76cff477', // span - 'strong', - 'style', - 'sub', - 'summary', - 'sup', - 'table', - 'tbody', - 'td', - 'textarea', - 'tfoot', - 'thead', - 'th', - 'time', - 'title', - 'track', - 'tr', - 'tt', - 'ul', - 'u', - 'var', - 'video', - 'wbr', - ]; - - /** - * @inheritDoc - */ - public $keywords5 = [ - // modifying - 'darken', - 'lighten', - 'saturate', - 'desaturate', - 'fadein', - 'fadeout', - 'fade', - 'spin', - 'mix', - // reading - 'lightness', - 'hue', - 'saturation', - 'alpha', - 'percentage', - // typechecking - 'isnumber', - 'iscolor', - 'isstring', - 'iskeyword', - 'isurl', - 'ispixel', - 'ispercentage', - 'isem', - // math - 'round', - 'ceil', - 'floor', - // if - 'when', - 'not', - 'and', - 'true', - // others - '&', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/DiffHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/DiffHighlighter.class.php deleted file mode 100644 index 36445c5b99..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/DiffHighlighter.class.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class DiffHighlighter extends Highlighter -{ - /** - * keywords for an added line, the + is used in unified diffs, the > in - * normal diffs - * @var string[] - */ - protected $add = ["+", ">"]; - - /** - * keywords for an deleted line, the - is used in unified diff, the < in - * normal diffs - * @var string[] - */ - protected $delete = ["-", "<"]; - - /** - * splitter in changes for normal diff - * @var string[] - */ - protected $splitter = ["---"]; - - /** - * keywords for the line info, the @ is used in unified diffs, the numbers - * in normal diffs - * @var string[] - */ - protected $info = ["@", '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - - /** - * @inheritDoc - */ - public function highlight($string) - { - $lines = \explode("\n", $string); - foreach ($lines as $key => $val) { - if (\in_array(\mb_substr($val, 0, 1), $this->info) || \in_array($val, $this->splitter)) { - $lines[$key] = '' . StringUtil::encodeHTML($val) . ''; - } elseif (\in_array(\mb_substr($val, 0, 1), $this->add)) { - $lines[$key] = '' . StringUtil::encodeHTML($val) . ''; - } elseif (\in_array(\mb_substr($val, 0, 1), $this->delete)) { - $lines[$key] = '' . StringUtil::encodeHTML($val) . ''; - } else { - $lines[$key] = StringUtil::encodeHTML($val); - } - } - - return \implode("\n", $lines); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php deleted file mode 100644 index c59daf4866..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php +++ /dev/null @@ -1,415 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -abstract class Highlighter extends SingletonFactory -{ - /** - * allow multiline quotes - * @var bool - */ - protected $allowsNewslinesInQuotes = false; - - /** - * comment end delimiter - * @var string[] - */ - protected $commentEnd = ["*/"]; - - /** - * comment start delimiter - * @var string[] - */ - protected $commentStart = ["/*"]; - - /** - * escape sequence - * @var string[] - */ - protected $escapeSequence = ["\\"]; - - /** - * categorized keywords - * @var string[] - */ - protected $keywords1 = []; - - /** - * categorized keywords - * @var string[] - */ - protected $keywords2 = []; - - /** - * categorized keywords - * @var string[] - */ - protected $keywords3 = []; - - /** - * categorized keywords - * @var string[] - */ - protected $keywords4 = []; - - /** - * categorized keywords - * @var string[] - */ - protected $keywords5 = []; - - /** - * list of arithmetic operators - * @var string[] - */ - protected $operators = []; - - /** - * list of quote marks - * @var string[] - */ - protected $quotes = ["'", '"']; - - /** - * list of separator sequences - * @var string[] - */ - protected $separators = []; - - /** - * inline comment sequence - * @var string[] - */ - protected $singleLineComment = ["//"]; - - /** - * regular expression to extract comments - * @var Regex - */ - public $cacheCommentsRegEx; - - /** - * regular expression to find quote marks - * @var Regex - */ - public $quotesRegEx; - - /** - * regular expression to find string separators - * @var string - */ - public $separatorsRegEx = ''; - - /** - * @inheritDoc - */ - protected function init() - { - $this->buildRegularExpressions(); - } - - /** - * Returns the title of this highlighter. - * - * @return string - */ - public function getTitle() - { - // regex to extract the Highlighter out of the namespaced classname - $reType = new Regex('\\\\?wcf\\\\system\\\\bbcode\\\\highlighter\\\\(.*)Highlighter', Regex::CASE_INSENSITIVE); - - return WCF::getLanguage()->get('wcf.bbcode.code.' . $reType->replace( - \strtolower(static::class), - '\1' - ) . '.title'); - } - - /** - * Highlights syntax of source code. - * - * @param string $string - * @return string - */ - public function highlight($string) - { - // cache comments - $string = $this->cacheComments($string); - - // cache quotes - $string = $this->cacheQuotes($string); - - // encode html - $string = StringUtil::encodeHTML($string); - - // do highlight - $string = $this->highlightOperators($string); - $string = $this->highlightKeywords($string); - $string = $this->highlightNumbers($string); - - // insert and highlight quotes - $string = $this->highlightQuotes($string); - - // insert and highlight comments - return $this->highlightComments($string); - } - - /** - * Builds regular expressions. - */ - protected function buildRegularExpressions() - { - // quotes regex - $quotedEscapeSequence = \preg_quote(\implode('', $this->escapeSequence)); - $quotesRegEx = ''; - foreach ($this->quotes as $quote) { - if ($quotesRegEx !== '') { - $quotesRegEx .= '|'; - } - if (!\is_array($quote)) { - $quote = [$quote, $quote]; - } - [$opening, $closing] = $quote; - - $opening = \preg_quote($opening); - $closing = \preg_quote($closing); - - if ($quotedEscapeSequence) { - $quotesRegEx .= $opening . '(?>[^' . $closing . $quotedEscapeSequence . ']+|(?:' . $quotedEscapeSequence . '.)+)*' . $closing; - } else { - $quotesRegEx .= $opening . '(?>[^' . $closing . $quotedEscapeSequence . '])*' . $closing; - } - } - - if ($quotesRegEx !== '') { - $quotesRegEx = '(?:' . $quotesRegEx . ')'; - $this->quotesRegEx = new Regex( - $quotesRegEx, - $this->allowsNewslinesInQuotes ? Regex::DOT_ALL : Regex::MODIFIER_NONE - ); - } - - // cache comment regex - if (!empty($this->singleLineComment) || !empty($this->commentStart)) { - $cacheCommentsRegEx = ''; - - if ($quotesRegEx !== '') { - $cacheCommentsRegEx .= "(" . $quotesRegEx . ")|"; - } else { - $cacheCommentsRegEx .= "()"; - } - - $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 .= '|'; - } - } - - if (!empty($this->singleLineComment)) { - $cacheCommentsRegEx .= "(?:" . \implode( - '|', - \array_map('preg_quote', $this->singleLineComment) - ) . ")[^\n]*"; - } - - $cacheCommentsRegEx .= ")"; - - $this->cacheCommentsRegEx = new Regex($cacheCommentsRegEx, Regex::DOT_ALL); - } - - $this->separatorsRegEx = StringUtil::encodeHTML(\implode( - '|', - \array_map('preg_quote', $this->separators) - )) . '|\s| |^|$|>|<'; - } - - /** - * Caches comments. - * - * @param string $string - * @return string - */ - protected function cacheComments($string) - { - if ($this->cacheCommentsRegEx !== null) { - $string = $this->cacheCommentsRegEx->replace($string, static function (array $matches) { - $string = $matches[1]; - if (isset($matches[2])) { - $comment = $matches[2]; - } else { - $comment = ''; - } - - $hash = ''; - if (!empty($comment)) { - // create hash - $hash = StringStack::pushToStringStack( - '' . StringUtil::encodeHTML($comment) . '', - 'highlighterComments' - ); - } - - return $string . $hash; - }); - } - - return $string; - } - - /** - * Caches quotes. - * - * @param string $string - * @return string - */ - protected function cacheQuotes($string) - { - if ($this->quotesRegEx !== null) { - $string = $this->quotesRegEx->replace($string, static function (array $matches) { - return StringStack::pushToStringStack( - '' . StringUtil::encodeHTML($matches[0]) . '', - 'highlighterQuotes' - ); - }); - } - - return $string; - } - - /** - * Highlights operators. - * - * @param string $string - * @return string - */ - protected function highlightOperators($string) - { - if (!empty($this->operators)) { - $string = \preg_replace( - '!(' . StringUtil::encodeHTML(\implode( - '|', - \array_map('preg_quote', $this->operators) - )) . ')!i', - '\\0', - $string - ); - } - - return $string; - } - - /** - * Highlights keywords. - * - * @param string $string - * @return string - */ - protected function highlightKeywords($string) - { - $_this = $this; - $buildKeywordRegex = static function (array $keywords) use ($_this) { - return '!(?<=' . $_this->separatorsRegEx . ')(' . StringUtil::encodeHTML(\implode( - '|', - \array_map('preg_quote', $keywords) - )) . ')(?=' . $_this->separatorsRegEx . ')!i'; - }; - - if (!empty($this->keywords1)) { - $string = \preg_replace( - $buildKeywordRegex($this->keywords1), - '\\0', - $string - ); - } - if (!empty($this->keywords2)) { - $string = \preg_replace( - $buildKeywordRegex($this->keywords2), - '\\0', - $string - ); - } - if (!empty($this->keywords3)) { - $string = \preg_replace( - $buildKeywordRegex($this->keywords3), - '\\0', - $string - ); - } - if (!empty($this->keywords4)) { - $string = \preg_replace( - $buildKeywordRegex($this->keywords4), - '\\0', - $string - ); - } - if (!empty($this->keywords5)) { - $string = \preg_replace( - $buildKeywordRegex($this->keywords5), - '\\0', - $string - ); - } - - return $string; - } - - /** - * Highlights numbers. - * - * @param string $string - * @return string - */ - protected function highlightNumbers($string) - { - return \preg_replace( - '!(?<=' . $this->separatorsRegEx . ')(-?\d+)(?=' . $this->separatorsRegEx . ')!i', - '\\0', - $string - ); - } - - /** - * Highlights quotes. - * - * @param string $string - * @return string - */ - protected function highlightQuotes($string) - { - return StringStack::reinsertStrings($string, 'highlighterQuotes'); - } - - /** - * Highlights comments. - * - * @param string $string - * @return string - */ - protected function highlightComments($string) - { - return StringStack::reinsertStrings($string, 'highlighterComments'); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/HtmlHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/HtmlHighlighter.class.php deleted file mode 100644 index ac1c97b19f..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/HtmlHighlighter.class.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class HtmlHighlighter extends XmlHighlighter -{ - /** - * @inheritDoc - */ - protected function cacheComments($string) - { - // cache inline scripts and inline css - $string = $this->cacheScriptsAndStyles($string); - - return parent::cacheComments($string); - } - - /** - * Caches scripts and styles in the given string. - * - * @param string $string - * @return string - */ - protected function cacheScriptsAndStyles($string) - { - $regex = new Regex('(<(style|script)[^>]*>)(.*?)()', Regex::CASE_INSENSITIVE | Regex::DOT_ALL); - - return $regex->replace($string, static function ($matches) { - $type = ($matches[2] === 'script') ? 'js' : 'css'; - - // strip slashes - $content = \str_replace('\\"', '"', $matches[3]); - $openingTag = \str_replace('\\"', '"', $matches[1]); - $closingTag = \str_replace('\\"', '"', $matches[4]); - - if (StringUtil::trim($content) == '') { - return $matches[0]; - } - - $class = '\wcf\system\bbcode\highlighter\\' . \ucfirst($type) . 'Highlighter'; - - /** @noinspection PhpUndefinedMethodInspection */ - return $openingTag . StringStack::pushToStringStack( - '' . $class::getInstance()->highlight($content) . '', - 'htmlHighlighter' . \ucfirst($type) - ) . $closingTag; - }); - } - - /** - * @inheritDoc - */ - protected function highlightComments($string) - { - $string = parent::highlightComments($string); - - // highlight script and style blocks - $string = StringStack::reinsertStrings($string, 'htmlHighlighterJs'); - - return StringStack::reinsertStrings($string, 'htmlHighlighterCss'); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/JavaHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/JavaHighlighter.class.php deleted file mode 100644 index 9d7be09b82..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/JavaHighlighter.class.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class JavaHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = ["(", ")", "{", "}", "[", "]", ";", ".", ",", "<", ">"]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'package', - 'abstract', - 'break', - 'case', - 'catch', - 'class', - 'continue', - 'default', - 'do', - 'else', - 'extends', - 'false', - 'finally', - 'for', - 'goto', - 'if', - 'implements', - 'instanceof', - 'interface', - 'native', - 'new', - 'null', - 'private', - 'protected', - 'public', - 'return', - 'super', - 'strictfp', - 'switch', - 'synchronized', - 'this', - 'throws', - 'throw', - 'transient', - 'true', - 'try', - 'volatile', - 'while', - 'boolean', - 'byte', - 'char', - 'const', - 'double', - 'final', - 'float', - 'int', - 'long', - 'short', - 'static', - 'void', - 'import', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - 'Boolean', - 'Float', - 'Character', - 'Double', - 'Enum', - 'Long', - 'Short', - 'Integer', - 'Math', - 'Object', - 'String', - 'StringBuffer', - 'System', - 'Thread', - 'Exception', - 'Throwable', - 'Runnable', - 'Appendable', - 'Cloneable', - 'HashMap', - 'List', - 'ArrayList', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/JsHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/JsHighlighter.class.php deleted file mode 100644 index 7958242861..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/JsHighlighter.class.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class JsHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = ["(", ")", "{", "}", "[", "]", ";", ".", ","]; - - /** - * @inheritDoc - */ - protected $operators = [ - "=", - ">", - "<", - "!", - "~", - "?", - ":", - "==", - "<=", - ">=", - "!=", - "&&", - "||", - "++", - "--", - "+", - "-", - "*", - "/", - "&", - "|", - "^", - "%", - "<<", - ">>", - ">>>", - "+=", - "-=", - "*=", - "/=", - "&=", - "|=", - "^=", - "%=", - "<<=", - ">>=", - ">>>=", - ]; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - "String", - "Array", - "RegExp", - "Function", - "Math", - "Number", - "Date", - "Image", - "window", - "document", - "navigator", - "onAbort", - "onBlur", - "onChange", - "onClick", - "onDblClick", - "onDragDrop", - "onError", - "onFocus", - "onKeyDown", - "onKeyPress", - "onKeyUp", - "onLoad", - "onMouseDown", - "onMouseOver", - "onMouseOut", - "onMouseMove", - "onMouseUp", - "onMove", - "onReset", - "onResize", - "onSelect", - "onSubmit", - "onUnload", - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - "break", - "continue", - "do", - "while", - "export", - "for", - "in", - "if", - "else", - "import", - "return", - "label", - "switch", - "case", - "var", - "with", - "delete", - "new", - "this", - "typeof", - "void", - "abstract", - "boolean", - "byte", - "catch", - "char", - "class", - "const", - "debugger", - "default", - "double", - "enum", - "extends", - "false", - "final", - "finally", - "float", - "function", - "implements", - "goto", - "instanceof", - "int", - "interface", - "long", - "native", - "null", - "package", - "private", - "protected", - "public", - "short", - "static", - "super", - "synchronized", - "throw", - "throws", - "transient", - "true", - "try", - "volatile", - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/PerlHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/PerlHighlighter.class.php deleted file mode 100644 index 0b373bc6b3..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/PerlHighlighter.class.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class PerlHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = ['(', ')', '{', '}', '[', ']', ';', '.', ',']; - - /** - * @inheritDoc - */ - protected $singleLineComment = ['#']; - - /** - * @inheritDoc - */ - protected $commentStart = []; - - /** - * @inheritDoc - */ - protected $commentEnd = []; - - /** - * @inheritDoc - */ - protected $operators = [ - '.=', - '=', - '>', - '<', - '!', - '~', - '?', - ':', - '==', - '<=', - '>=', - '!=', - '&&', - '||', - '++', - '--', - '+', - '-', - '*', - '/', - '&', - '|', - '^', - '%', - '<<', - '>>', - '>>>', - '+=', - '-=', - '*=', - '/=', - '&=', - '|=', - '^=', - '%=', - '<<=', - '>>=', - '>>>=', - '->', - '::', - ]; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'print', - 'sprintf', - 'length', - 'substr', - 'eval', - 'die', - 'opendir', - 'closedir', - 'open', - 'close', - 'chmod', - 'unlink', - 'flock', - 'read', - 'seek', - 'stat', - 'truncate', - 'chomp', - 'localtime', - 'defined', - 'undef', - 'uc', - 'lc', - 'trim', - 'split', - 'sort', - 'keys', - 'push', - 'pop', - 'join', - 'local', - 'select', - 'index', - 'sqrt', - 'system', - 'crypt', - 'pack', - 'unpack', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'case', - 'do', - 'while', - 'for', - 'if', - 'foreach', - 'my', - 'else', - 'elsif', - 'eq', - 'ne', - 'or', - 'xor', - 'and', - 'lt', - 'gt', - 'ge', - 'le', - 'return', - 'last', - 'goto', - 'unless', - 'given', - 'when', - 'default', - 'until', - 'break', - 'exit', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - 'use', - 'import', - 'require', - 'sub', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/PhpHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/PhpHighlighter.class.php deleted file mode 100644 index 2b23f16764..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/PhpHighlighter.class.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class PhpHighlighter extends Highlighter -{ - public static $colorToClass = []; - - /** - * @inheritDoc - */ - protected function init() - { - parent::init(); - - $types = [ - 'default' => 'hlKeywords1', - 'keyword' => 'hlKeywords2', - 'comment' => 'hlComments', - 'string' => 'hlQuotes', - ]; - - self::$colorToClass[''] = ''; - foreach ($types as $type => $class) { - self::$colorToClass[''] = ''; - } - } - - /** - * @inheritDoc - */ - public function highlight($string) - { - // add starting php tag - $phpTagsAdded = false; - if (!\str_contains($string, ''; - } - - // do highlight - $highlightedCode = \highlight_string($string, true); - - // clear code - $highlightedCode = \str_replace('', '', $highlightedCode); - $highlightedCode = \str_replace('', '', $highlightedCode); - - // remove added php tags - if ($phpTagsAdded) { - // the opening and closing PHP tags were added previously, hence we actually do - // know that the first (last for the closing tag) occurrence is the one inserted - // by us. The previously used regex was bad because it was significantly slower - // and could easily hit the backtrace limit for larger inputs - $openingTag = \mb_strpos($highlightedCode, '<?php '); - $closingTag = \mb_strrpos($highlightedCode, '?>'); - $tmp = \mb_substr($highlightedCode, 0, $openingTag); - $tmp .= \mb_substr($highlightedCode, $openingTag + 14, $closingTag - $openingTag - 14); - $tmp .= \mb_substr($highlightedCode, $closingTag + 5); - - $highlightedCode = $tmp; - } - - // remove breaks - $highlightedCode = \str_replace("\n", "", $highlightedCode); - $highlightedCode = \str_replace('
', "\n", $highlightedCode); - $highlightedCode = \str_replace('
', "\n", $highlightedCode); - - // get tabs back - $highlightedCode = \str_replace('    ', "\t", $highlightedCode); - // replace non breaking space with normal space, white-space is preserved by CSS - $highlightedCode = \str_replace(' ', " ", $highlightedCode); - - // convert colors to classes - $highlightedCode = \strtr($highlightedCode, self::$colorToClass); - - // replace double quotes by entity - return Regex::compile('(?)')->replace($highlightedCode, '"'); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/PlainHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/PlainHighlighter.class.php deleted file mode 100644 index 33b2b619fc..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/PlainHighlighter.class.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class PlainHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - public function highlight($string) - { - return StringUtil::encodeHTML($string); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/PythonHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/PythonHighlighter.class.php deleted file mode 100644 index 43259135af..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/PythonHighlighter.class.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class PythonHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $separators = [ - '(', - ')', /* from __future__ import braces '{', '}', */ - '[', - ']', - ';', - '.', - ',', - ':', - ]; - - /** - * @inheritDoc - */ - protected $singleLineComment = ['#']; - - /** - * @inheritDoc - */ - protected $commentStart = []; - - /** - * @inheritDoc - */ - protected $commentEnd = []; - - /** - * @inheritDoc - */ - protected $operators = [ - '+=', - '-=', - '**=', - '*=', - '//=', - '/=', - '%=', - '~=', - '+', - '-', - '**', - '*', - '//', - '/', - '%', - '&=', - '<<=', - '>>=', - '^=', - '~', - '&', - '^', - '|', - '<<', - '>>', - '=', - '!=', - '<', - '>', - '<=', - '>=', - ]; - - /** - * @inheritDoc - */ - protected $quotes = [["r'", "'"], ["u'", "'"], ['r"', '"'], ['u"', '"'], "'", '"']; - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'print', - 'del', - 'str', - 'int', - 'len', - 'repr', - 'range', - 'raise', - 'pass', - 'continue', - 'break', - 'return', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'if', - 'elif', - 'else', - 'try', - 'except', - 'finally', - 'for', - 'in', - 'while', - ]; - - /** - * @inheritDoc - */ - protected $keywords3 = [ - 'from', - 'import', - 'as', - 'class', - 'def', - ]; - - /** - * @inheritDoc - */ - protected $keywords4 = [ - '__name__', - '__init__', - '__str__', - '__del__', - 'self', - 'True', - 'False', - 'None', - 'and', - 'or', - 'not', - 'is', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/SqlHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/SqlHighlighter.class.php deleted file mode 100644 index 570962999a..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/SqlHighlighter.class.php +++ /dev/null @@ -1,468 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class SqlHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $allowsNewslinesInQuotes = true; - - /** - * @inheritDoc - */ - protected $quotes = ["'", '"']; - - /** - * @inheritDoc - */ - protected $singleLineComment = ['#', '--']; - - /** - * @inheritDoc - */ - protected $separators = ['(', ')', ',', ';']; - - /** - * @inheritDoc - */ - protected $operators = [ - '<>', - '~=', - '!=', - '^=', - '=', - '<', - '<=', - '>', - '>=', - '*', - '/', - '+', - '-', - '||', - '@', - '%', - '&', - '?', - '\$', - ]; - - /** - * @inheritDoc - */ - protected function cacheComments($string) - { - if ($this->cacheCommentsRegEx !== null) { - $string = $this->cacheCommentsRegEx->replace($string, static function (array $matches) { - $string = $matches[1]; - if (isset($matches[2])) { - $comment = $matches[2]; - } else { - $comment = ''; - } - - // strip slashes - $string = \str_replace("\\\"", "\"", $string); - $hash = ''; - if (!empty($comment)) { - $comment = \str_replace("\\\"", "\"", $comment); - - // create hash - $hash = StringStack::pushToStringStack( - '' . StringUtil::encodeHTML($comment) . '', - 'highlighterComments', - "\0\0" - ); - } - - return $string . $hash; - }); - } - - return $string; - } - - /** - * @inheritDoc - */ - protected function cacheQuotes($string) - { - if ($this->quotesRegEx !== null) { - $string = $this->quotesRegEx->replace($string, static function (array $matches) { - return StringStack::pushToStringStack( - '' . StringUtil::encodeHTML($matches[0]) . '', - 'highlighterQuotes', - "\0\0" - ); - }); - } - - return $string; - } - - /** - * @inheritDoc - */ - protected $keywords1 = [ - 'action', - 'add', - 'aggregate', - 'all', - 'alter', - 'after', - 'and', - 'as', - 'asc', - 'avg', - 'avg_row_length', - 'auto_increment', - 'between', - 'bigint', - 'bit', - 'binary', - 'blob', - 'bool', - 'both', - 'by', - 'cascade', - 'case', - 'char', - 'character', - 'change', - 'check', - 'checksum', - 'column', - 'columns', - 'comment', - 'constraint', - 'create', - 'cross', - 'current_date', - 'current_time', - 'current_timestamp', - 'data', - 'database', - 'databases', - 'date', - 'datetime', - 'day', - 'day_hour', - 'day_minute', - 'day_second', - 'dayofmonth', - 'dayofweek', - 'dayofyear', - 'dec', - 'decimal', - 'default', - 'delayed', - 'delay_key_write', - 'delete', - 'desc', - 'describe', - 'distinct', - 'distinctrow', - 'double', - 'drop', - 'end', - 'else', - 'escape', - 'escaped', - 'enclosed', - 'enum', - 'explain', - 'exists', - 'fields', - 'file', - 'first', - 'float', - 'float4', - 'float8', - 'flush', - 'foreign', - 'from', - 'for', - 'full', - 'function', - 'global', - 'grant', - 'grants', - 'group', - 'having', - 'heap', - 'high_priority', - 'hour', - 'hour_minute', - 'hour_second', - 'hosts', - 'identified', - 'ignore', - 'in', - 'index', - 'infile', - 'inner', - 'insert', - 'insert_id', - 'int', - 'integer', - 'interval', - 'int1', - 'int2', - 'int3', - 'int4', - 'int8', - 'into', - 'if', - 'is', - 'isam', - 'join', - 'key', - 'keys', - 'kill', - 'last_insert_id', - 'leading', - 'left', - 'length', - 'like', - 'lines', - 'limit', - 'load', - 'local', - 'lock', - 'logs', - 'long', - 'longblob', - 'longtext', - 'low_priority', - 'max', - 'max_rows', - 'match', - 'mediumblob', - 'mediumtext', - 'mediumint', - 'middleint', - 'min_rows', - 'minute', - 'minute_second', - 'modify', - 'month', - 'monthname', - 'myisam', - 'natural', - 'numeric', - 'no', - 'not', - 'null', - 'on', - 'optimize', - 'option', - 'optionally', - 'or', - 'order', - 'outer', - 'outfile', - 'pack_keys', - 'partial', - 'password', - 'precision', - 'primary', - 'procedure', - 'process', - 'processlist', - 'privileges', - 'read', - 'real', - 'references', - 'reload', - 'regexp', - 'rename', - 'replace', - 'restrict', - 'returns', - 'revoke', - 'rlike', - 'row', - 'rows', - 'second', - 'select', - 'set', - 'show', - 'shutdown', - 'smallint', - 'soname', - 'sql_big_tables', - 'sql_big_selects', - 'sql_low_priority_updates', - 'sql_log_off', - 'sql_log_update', - 'sql_select_limit', - 'sql_small_result', - 'sql_big_result', - 'sql_warnings', - 'straight_join', - 'starting', - 'status', - 'string', - 'table', - 'tables', - 'temporary', - 'terminated', - 'text', - 'then', - 'time', - 'timestamp', - 'tinyblob', - 'tinytext', - 'tinyint', - 'trailing', - 'to', - 'type', - 'use', - 'using', - 'unique', - 'unlock', - 'unsigned', - 'update', - 'usage', - 'values', - 'varchar', - 'variables', - 'varying', - 'varbinary', - 'with', - 'write', - 'when', - 'where', - 'year', - 'year_month', - 'zerofill', - ]; - - /** - * @inheritDoc - */ - protected $keywords2 = [ - 'ABS', - 'ACOS', - 'ADDDATE', - 'ASCII', - 'ASIN', - 'ATAN', - 'ATAN2', - 'AVG', - 'BENCHMARK', - 'BIN', - 'CEILING', - 'CHAR', - 'COALESCE', - 'CONCAT', - 'CONV', - 'COS', - 'COT', - 'COUNT', - 'CURDATE', - 'CURTIME', - 'DATABASE', - 'DAYNAME', - 'DAYOFMONTH', - 'DAYOFWEEK', - 'DAYOFYEAR', - 'DECODE', - 'DEGREES', - 'ELT', - 'ENCODE', - 'ENCRYPT', - 'EXP', - 'EXTRACT', - 'FIELD', - 'FLOOR', - 'FORMAT', - 'GREATEST', - 'HEX', - 'HOUR', - 'IF', - 'IFNULL', - 'INSERT', - 'INSTR', - 'INTERVAL', - 'ISNULL', - 'LCASE', - 'LEAST', - 'LEFT', - 'LENGTH', - 'LOCATE', - 'LOCATE', - 'LOG', - 'LOG10', - 'LOWER', - 'LPAD', - 'LTRIM', - 'MAX', - 'MD5', - 'MID', - 'MIN', - 'MINUTE', - 'MOD', - 'MONTH', - 'MONTHNAME', - 'NOW', - 'NULLIF', - 'OCT', - 'ORD', - 'PASSWORD', - 'PI', - 'POSITION', - 'POW', - 'POWER', - 'prepare', - 'QUARTER', - 'RADIANS', - 'RAND', - 'REPEAT', - 'REPLACE', - 'REVERSE', - 'RIGHT', - 'ROUND', - 'ROUND', - 'RPAD', - 'RTRIM', - 'SECOND', - 'SIGN', - 'SIN', - 'SOUNDEX', - 'SPACE', - 'SQRT', - 'STD', - 'STDDEV', - 'STRCMP', - 'SUBDATE', - 'SUBSTRING', - 'SUBSTRING', - 'SUM', - 'SYSDATE', - 'TAN', - 'TRIM', - 'TRUNCATE', - 'UCASE', - 'UPPER', - 'USER', - 'VERSION', - 'WEEK', - 'WEEKDAY', - 'YEAR', - ]; -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/TexHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/TexHighlighter.class.php deleted file mode 100644 index 79544d0757..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/TexHighlighter.class.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class TexHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $quotes = []; - - /** - * @inheritDoc - */ - protected $singleLineComment = ['%']; - - /** - * @inheritDoc - */ - protected function highlightKeywords($string) - { - $string = Regex::compile('\\$([^\\$]*)\\$', Regex::DOT_ALL)->replace( - $string, - '\\0' - ); - $string = Regex::compile( - '(\\\\(?:[a-z]+))(\\[[^\\]\\\\]+\\])?(\\{[^\\}]*\\})?', - Regex::CASE_INSENSITIVE - )->replace( - $string, - '\\1\\2\\3' - ); - - return \str_replace('\\\\', '\\\\', $string); - } - - /** - * @inheritDoc - */ - protected function highlightNumbers($string) - { - // do not highlight numbers - return $string; - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/TplHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/TplHighlighter.class.php deleted file mode 100644 index 969d6bc00e..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/TplHighlighter.class.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class TplHighlighter extends HtmlHighlighter -{ - /** - * @inheritDoc - */ - protected function highlightComments($string) - { - $string = parent::highlightComments($string); - - // highlight template tags - return Regex::compile('\{(?=\S).+?(?<=\S)\}', Regex::DOT_ALL)->replace( - $string, - '\\0' - ); - } -} diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/XmlHighlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/XmlHighlighter.class.php deleted file mode 100644 index 3ed8cbf3d0..0000000000 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/XmlHighlighter.class.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @package WoltLabSuite\Core\System\Bbcode\Highlighter - * @deprecated since 5.2, use Prism to highlight your code. - */ -class XmlHighlighter extends Highlighter -{ - /** - * @inheritDoc - */ - protected $allowsNewslinesInQuotes = true; - - /** - * @inheritDoc - */ - protected $quotes = ['"']; - - /** - * @inheritDoc - */ - protected $singleLineComment = []; - - /** - * @inheritDoc - */ - protected $commentStart = [""]; - - /** - * @inheritDoc - */ - protected $separators = ["<", ">"]; - - /** - * @inheritDoc - */ - protected $operators = []; - - const XML_ATTRIBUTE_NAME = '[a-z0-9](?:(?:(?replace($string, static function ($matches) { - // highlight attributes - $tag = Regex::compile( - self::XML_ATTRIBUTE_NAME . '(?:=[^\s/\?&]+)?(?=\s|&)', - Regex::CASE_INSENSITIVE - )->replace($matches[0], '\\0'); - - // highlight tag - return '' . $tag . ''; - }); - - return $string; - } - - /** - * @inheritDoc - */ - protected function cacheQuotes($string) - { - $string = parent::cacheQuotes($string); - - // highlight CDATA-Tags as quotes - $string = Regex::compile('', Regex::DOT_ALL)->replace( - $string, - static function (array $matches) { - return StringStack::pushToStringStack( - '' . StringUtil::encodeHTML($matches[0]) . '', - 'highlighterQuotes' - ); - } - ); - - return $string; - } - - /** - * @inheritDoc - */ - protected function highlightQuotes($string) - { - return StringStack::reinsertStrings(parent::highlightQuotes($string), 'highlighterQuotes'); - } - - /** - * @inheritDoc - */ - protected function highlightNumbers($string) - { - // do not highlight numbers - return $string; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/BBCodeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/BBCodeCacheBuilder.class.php index d71c982068..af85a28b09 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/BBCodeCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/BBCodeCacheBuilder.class.php @@ -22,7 +22,7 @@ class BBCodeCacheBuilder extends AbstractCacheBuilder protected function rebuild(array $parameters) { $attributes = []; - $data = ['bbcodes' => [], 'highlighters' => []]; + $data = ['bbcodes' => []]; // get attributes $sql = "SELECT attribute.*, bbcode.bbcodeTag @@ -55,16 +55,6 @@ class BBCodeCacheBuilder extends AbstractCacheBuilder $data['bbcodes'][$bbcode->bbcodeTag] = $bbcode; } - // get code highlighters - $highlighters = \glob(WCF_DIR . 'lib/system/bbcode/highlighter/*.class.php'); - if (\is_array($highlighters)) { - foreach ($highlighters as $highlighter) { - if (\preg_match('~\/([a-zA-Z]+)Highlighter\.class\.php$~', $highlighter, $matches)) { - $data['highlighters'][] = \strtolower($matches[1]); - } - } - } - return $data; } }