From: <var...@us...> - 2014-09-12 09:48:13
|
Revision: 9070 http://sourceforge.net/p/phpwiki/code/9070 Author: vargenau Date: 2014-09-12 09:48:10 +0000 (Fri, 12 Sep 2014) Log Message: ----------- Trap recursive includes Modified Paths: -------------- trunk/lib/plugin/IncludePage.php trunk/lib/plugin/Template.php Modified: trunk/lib/plugin/IncludePage.php =================================================================== --- trunk/lib/plugin/IncludePage.php 2014-09-11 14:08:59 UTC (rev 9069) +++ trunk/lib/plugin/IncludePage.php 2014-09-12 09:48:10 UTC (rev 9070) @@ -87,8 +87,12 @@ // A page can include itself once (this is needed, e.g., when editing // TextFormattingRules). - static $included_pages = array(); - if (in_array($page, $included_pages)) { + // Protect from recursive inclusion. + static $rootpage = ''; + if ($rootpage == '') { + $rootpage = $basepage; + } + if ($page == $rootpage) { return $this->error(sprintf(_("Recursive inclusion of page %s ignored"), $page)); } @@ -132,7 +136,7 @@ $m[1] = substr($m[1], 1, -1); } // trap recursive redirects - if (in_array($m[1], $included_pages)) { + if ($m[1] == $rootpage) { return $this->error(sprintf(_("Recursive inclusion of page %s ignored"), $page . ' => ' . $m[1])); } @@ -151,13 +155,9 @@ // only in expansion $ct = preg_replace("/<includeonly>(.+)<\/includeonly>/s", "\\1", $ct); - array_push($included_pages, $page); - include_once 'lib/BlockParser.php'; $content = TransformText($ct, $page); - array_pop($included_pages); - if ($quiet) return $content; Modified: trunk/lib/plugin/Template.php =================================================================== --- trunk/lib/plugin/Template.php 2014-09-11 14:08:59 UTC (rev 9069) +++ trunk/lib/plugin/Template.php 2014-09-12 09:48:10 UTC (rev 9070) @@ -119,10 +119,13 @@ $page = "Template/" . $page; } - // Protect from recursive inclusion. A page can include itself once - static $included_pages = array(); - if (in_array($page, $included_pages)) { - return $this->error(sprintf(_("Recursive inclusion of page %s"), + // Protect from recursive inclusion. + static $rootpage = ''; + if ($rootpage == '') { + $rootpage = $basepage; + } + if ($page == $rootpage) { + return $this->error(sprintf(_("Recursive inclusion of page %s ignored"), $page)); } @@ -166,7 +169,7 @@ $m[1] = substr($m[1], 1, -1); } // trap recursive redirects - if (in_array($m[1], $included_pages)) { + if ($m[1] == $rootpage) { return $this->error(sprintf(_("Recursive inclusion of page %s ignored"), $page . ' => ' . $m[1])); } @@ -191,8 +194,6 @@ $initial_content); $this->doVariableExpansion($initial_content, $vars, $basepage, $request); - array_push($included_pages, $page); - // If content is single-line, call TransformInline, else call TransformText $initial_content = trim($initial_content, "\n"); if (preg_match("/\n/", $initial_content)) { @@ -203,8 +204,6 @@ $content = TransformInline($initial_content, $page); } - array_pop($included_pages); - return $content; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |