cvs: smarty /libs Smarty_Compiler.class.php
[email protected] ("Monte Ohrt") Fri, 23 Feb 2007 19:40:01 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvsmohrt1172259601@cvsserver> |
mohrt Fri Feb 23 19:40:01 2007 UTC
Modified files:
/smarty/libs Smarty_Compiler.class.php
Log:
escape creating of language=php from interleaving
http://cvs.php.net/viewvc.cgi/smarty/libs/Smarty_Compiler.class.php?r1=1.391&r2=1.392&diff_format=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.391 smarty/libs/Smarty_Compiler.class.php:1.392
--- smarty/libs/Smarty_Compiler.class.php:1.391 Fri Feb 23 16:28:34 2007
+++ smarty/libs/Smarty_Compiler.class.php Fri Feb 23 19:40:01 2007
@@ -26,7 +26,7 @@
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.391 2007/02/23 16:28:34 mohrt Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.392 2007/02/23 19:40:01 mohrt Exp $ */
/**
* Template compiling class
@@ -281,7 +281,7 @@
/* loop through text blocks */
for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
/* match anything resembling php tags */
- if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
+ if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?\s*php\s*[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
/* replace tags with placeholders to prevent recursive replacements */
$sp_match[1] = array_unique($sp_match[1]);
usort($sp_match[1], '_smarty_sort_length');
@@ -307,7 +307,7 @@
}
}
}
-
+
/* Compile the template tags into PHP code. */
$compiled_tags = array();
for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
@@ -369,10 +369,12 @@
}
$compiled_content .= str_replace('<?',$tmp_id,$text_blocks[$i]);
- // escape created php tags
+ // escape php tags created by interleaving
$compiled_content = str_replace('<?',"<?php echo '<?' ?>\n",$compiled_content);
+ $compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~","<?php echo 'language=php' ?>\n",$compiled_content);
+
// recover legit tags
- $compiled_content = str_replace($tmp_id,'<?',$compiled_content);
+ $compiled_content = str_replace($tmp_id,'<?',$compiled_content);
// remove \n from the end of the file, if any
if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) {