hook InternalParseBeforeSanitize
authorDaniel Werner <daniel.werner@wikimedia.de>
Sun, 24 Jun 2012 20:43:17 +0000 (22:43 +0200)
committerReedy <reedy@wikimedia.org>
Wed, 4 Jul 2012 22:32:14 +0000 (23:32 +0100)
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
docs/hooks.txt
includes/parser/Parser.php

index cff8a8c..955f6e7 100644 (file)
@@ -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.
index 5bc70c8..70c334a 100644 (file)
@@ -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
index 74d1006..7991ca6 100644 (file)
@@ -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 ) );