From 3921515104e3e4c717a84034c86ad1032131a46e Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Sun, 24 Jun 2012 22:43:17 +0200 Subject: [PATCH] hook InternalParseBeforeSanitize This patch add the hook 'InternalParseBeforeSanitize' which gets called during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags. Change-Id: If32053f9304088d7943aa0c9e78716a644c34fe1 --- RELEASE-NOTES-1.20 | 2 ++ docs/hooks.txt | 10 +++++++++- includes/parser/Parser.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index cff8a8c5c6..955f6e7f1e 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -87,6 +87,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * Added new hook ParserAfterParse to allow extensions to affect parsed output after the parse is complete but before block level processing, link holder replacement, and so on. +* (bug 34678) Added InternalParseBeforeSanitize hook which gets called during Parser's + internalParse method just before the parser removes unwanted/dangerous HTML tags. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/docs/hooks.txt b/docs/hooks.txt index 5bc70c8749..70c334acec 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1129,8 +1129,16 @@ $prefix: interwiki prefix we are looking for. &$iwData: output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. +'InternalParseBeforeSanitize': during Parser's internalParse method just before the +parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/ +onlyinclude and other processings. Ideal for syntax-extensions after template/parser +function execution which respect nowiki and HTML-comments. +&$parser: Parser object +&$text: string containing partially parsed text +&$stripState: Parser's internal StripState object + 'InternalParseBeforeLinks': during Parser's internalParse method before links -but after noinclude/includeonly/onlyinclude and other processing. +but after nowiki/noinclude/includeonly/onlyinclude and other processings. &$parser: Parser object &$text: string containing partially parsed text &$stripState: Parser's internal StripState object diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 74d1006b13..7991ca602a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1122,6 +1122,7 @@ class Parser { $text = $this->replaceVariables( $text ); } + wfRunHooks( 'InternalParseBeforeSanitize', array( &$this, &$text, &$this->mStripState ) ); $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) ); wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) ); -- 2.20.1