Merge "define RC_EXTERNAL type for recent changes"
[lhc/web/wiklou.git] / includes / parser / Preprocessor_DOM.php
index e75237b..b2dd7db 100644 (file)
@@ -126,6 +126,7 @@ class Preprocessor_DOM implements Preprocessor {
         * cache may be implemented at a later date which takes further advantage of these strict
         * dependency requirements.
         *
+        * @throws MWException
         * @return PPNode_DOM
         */
        function preprocessToObj( $text, $flags = 0 ) {
@@ -162,6 +163,15 @@ class Preprocessor_DOM implements Preprocessor {
                        }
 
                }
+
+               // Fail if the number of elements exceeds acceptable limits
+               // Do not attempt to generate the DOM
+               $this->parser->mGeneratedPPNodeCount += substr_count( $xml, '<' );
+               $max = $this->parser->mOptions->getMaxGeneratedPPNodeCount();
+               if ( $this->parser->mGeneratedPPNodeCount > $max ) {
+                       throw new MWException( __METHOD__.': generated node count limit exceeded' );
+               }
+
                wfProfileIn( __METHOD__.'-loadXML' );
                $dom = new DOMDocument;
                wfSuppressWarnings();
@@ -1664,6 +1674,7 @@ class PPNode_DOM implements PPNode {
         *  - index         String index
         *  - value         PPNode value
         *
+        * @throws MWException
         * @return array
         */
        function splitArg() {
@@ -1685,6 +1696,7 @@ class PPNode_DOM implements PPNode {
         * Split an "<ext>" node into an associative array containing name, attr, inner and close
         * All values in the resulting array are PPNodes. Inner and close are optional.
         *
+        * @throws MWException
         * @return array
         */
        function splitExt() {
@@ -1710,6 +1722,7 @@ class PPNode_DOM implements PPNode {
 
        /**
         * Split a "<h>" node
+        * @throws MWException
         * @return array
         */
        function splitHeading() {