From 60a355056d4efdda383c483bce4aadca06f962cb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 14 May 2016 23:24:21 +0200 Subject: [PATCH] Added prototype BBCode -> HTML parser --- .../files/lib/form/MessageForm.class.php | 4 +- .../system/bbcode/HtmlBBCodeParser.class.php | 205 +++++++++ .../html/input/HtmlInputProcessor.class.php | 8 + .../filter/MessageHtmlInputFilter.class.php | 11 + .../node/HtmlInputNodeProcessor.class.php | 13 +- .../HtmlInputNodeWoltlabMention.class.php | 14 +- .../HtmlInputNodeWoltlabMetacode.class.php | 105 +++++ ...mlInputNodeWoltlabMetacodeMarker.class.php | 347 ++++++++++++++ .../html/input/node/IHtmlInputNode.class.php | 5 +- .../AbstractMetacodeConverter.class.php | 11 + .../ColorMetacodeConverter.class.php | 31 ++ .../converter/IMetacodeConverter.class.php | 25 ++ .../QuoteMetacodeConverter.class.php | 25 ++ .../html/node/AbstractHtmlNode.class.php | 14 + .../html/node/HtmlNodeProcessor.class.php | 41 ++ .../lib/system/html/node/IHtmlNode.class.php | 15 + .../output/HtmlOutputNodeProcessor.class.php | 42 +- .../node/HtmlOutputNodeBlockquote.class.php | 30 +- .../HtmlOutputNodeWoltlabMention.class.php | 29 +- .../output/node/IHtmlOutputNode.class.php | 8 +- .../install/files/lib/util/DOMUtil.class.php | 422 ++++++++++++++++++ 21 files changed, 1316 insertions(+), 89 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php create mode 100644 wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php create mode 100644 wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php create mode 100644 wcfsetup/install/files/lib/system/html/metacode/converter/AbstractMetacodeConverter.class.php create mode 100644 wcfsetup/install/files/lib/system/html/metacode/converter/ColorMetacodeConverter.class.php create mode 100644 wcfsetup/install/files/lib/system/html/metacode/converter/IMetacodeConverter.class.php create mode 100644 wcfsetup/install/files/lib/system/html/metacode/converter/QuoteMetacodeConverter.class.php create mode 100644 wcfsetup/install/files/lib/system/html/node/AbstractHtmlNode.class.php create mode 100644 wcfsetup/install/files/lib/system/html/node/IHtmlNode.class.php create mode 100644 wcfsetup/install/files/lib/util/DOMUtil.class.php diff --git a/wcfsetup/install/files/lib/form/MessageForm.class.php b/wcfsetup/install/files/lib/form/MessageForm.class.php index 677de11f4a..04b68237b6 100644 --- a/wcfsetup/install/files/lib/form/MessageForm.class.php +++ b/wcfsetup/install/files/lib/form/MessageForm.class.php @@ -267,13 +267,13 @@ abstract class MessageForm extends AbstractCaptchaForm { throw new UserInputException('text', 'tooLong'); } - if ($this->enableBBCodes && $this->allowedBBCodesPermission) { + /*if ($this->enableBBCodes && $this->allowedBBCodesPermission) { $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->text, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($this->allowedBBCodesPermission)))); if (!empty($disallowedBBCodes)) { WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes); throw new UserInputException('text', 'disallowedBBCodes'); } - } + }*/ // search for censored words if (ENABLE_CENSORSHIP) { diff --git a/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php new file mode 100644 index 0000000000..f164b31394 --- /dev/null +++ b/wcfsetup/install/files/lib/system/bbcode/HtmlBBCodeParser.class.php @@ -0,0 +1,205 @@ + + * that can be safely passed through HTMLPurifier's validation mechanism. + * + * All though not exactly required for all bbcodes, the actual output of an bbcode + * cannot be forseen and potentially conflict with HTMLPurifier's whitelist. Examples + * are