# HG changeset patch # User Dan # Date 1184173714 14400 # Node ID 2c57d3018a885677210c52dcb84834b91b7aed64 # Parent 9dc4fded30e61920eb9eca41450bf55d7989e35d Fixed recursive template inclusion and spaces in template tags ({{Foo template}}) diff -r 9dc4fded30e6 -r 2c57d3018a88 includes/render.php --- a/includes/render.php Wed Jul 11 13:00:19 2007 -0400 +++ b/includes/render.php Wed Jul 11 13:08:34 2007 -0400 @@ -255,7 +255,15 @@ } } - $text = RenderMan::include_templates($text); + $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + $i = 0; + while ( preg_match($template_regex, $text) ) + { + $i++; + if ( $i == 5 ) + break; + $text = RenderMan::include_templates($text); + } $text = process_tables($text); @@ -450,10 +458,11 @@ /** * Parses a partial template tag in wikitext, and return an array with the parameters. - * @param string The portion of the template tag that contains the parameters. Example: + * @param string The portion of the template tag that contains the parameters. + * @example * - * foo = lorem ipsum - * bar = dolor sit amet + foo = lorem ipsum + bar = dolor sit amet * * @return array Example: * [foo] => lorem ipsum @@ -519,11 +528,12 @@ function include_templates($text) { global $db, $session, $paths, $template, $plugins; // Common objects - $template_regex = "/\{\{([A-z0-9_-]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; if ( $count = preg_match_all($template_regex, $text, $matches) ) { for ( $i = 0; $i < $count; $i++ ) { + $matches[1][$i] = sanitize_page_id($matches[1][$i]); $parmsection = trim($matches[2][$i]); if ( !empty($parmsection) ) {