cvs: smarty / NEWS /libs Config_File.class.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1068024083@cvsserver>
messju		Wed Nov  5 04:21:23 2003 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Config_File.class.php 
  Log:
  fix handling if [...] inside triple-quotes in config-files
  
  
  
Index: smarty/NEWS
diff -u smarty/NEWS:1.399 smarty/NEWS:1.400
--- smarty/NEWS:1.399	Mon Oct 27 10:27:54 2003
+++ smarty/NEWS	Wed Nov  5 04:21:23 2003
@@ -1,4 +1,5 @@
-  - fix handling of simple-math-operators inside modifiers(Dominik, messju)
+  - fix handling if [...] inside triple-quotes in config-files (messju)
+  - fix handling of simple-math-operators inside modifiers (Dominik, messju)
   - fix handling of trailing-slashes in open_basedir in
     smarty_core_create_dir_structure() (packman, messju)
 
Index: smarty/libs/Config_File.class.php
diff -u smarty/libs/Config_File.class.php:1.54 smarty/libs/Config_File.class.php:1.55
--- smarty/libs/Config_File.class.php:1.54	Sat Oct 11 04:55:52 2003
+++ smarty/libs/Config_File.class.php	Wed Nov  5 04:21:23 2003
@@ -31,7 +31,7 @@
  * @package Smarty
  */
 
-/* $Id: Config_File.class.php,v 1.54 2003/10/11 08:55:52 messju Exp $ */
+/* $Id: Config_File.class.php,v 1.55 2003/11/05 09:21:23 messju Exp $ */
 /**
  * Config file reading class
  * @package Smarty
@@ -255,9 +255,15 @@
 
         $config_data = array();
 
+        /* replace all multi-line values by placeholders */
+        if (preg_match_all('/"""(.*)"""/Us', $contents, $match)) {
+            $_triple_quotes = $match[1];
+            $_i = 0;
+            $contents = preg_replace('/""".*"""/Use', '"\x1b\x1b\x1b".$_i++."\x1b\x1b\x1b"', $contents);
+        }
         /* Get global variables first. */
         if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match))
-            $config_data["vars"] = $this->_parse_config_block($match[1]);
+            $config_data["vars"] = $this->_parse_config_block($match[1], $_triple_quotes);
 
         /* Get section variables. */
         $config_data["sections"] = array();
@@ -268,7 +274,7 @@
             if (preg_match("/\[".preg_quote($section, '/')."\](.*?)(\n\[|\Z)/s", $contents, $match))
                 if ($section{0} == '.')
                     $section = substr($section, 1);
-                $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1]);
+                $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1], $_triple_quotes);
         }
 
         $this->_config_data[$config_file] = $config_data;
@@ -280,16 +286,16 @@
     /**
      * @var string $config_block
      */
-    function _parse_config_block($config_block)
+    function _parse_config_block($config_block, $triple_quotes)
     {
         $vars = array();
 
         /* First we grab the multi-line values. */
-        if (preg_match_all("/^([^=\n]+)=\s*\"{3}(.*?)\"{3}\s*$/ms", $config_block, $match, PREG_SET_ORDER)) {
+        if (preg_match_all("/^([^=\n]+)=\s*\x1b\x1b\x1b(\d+)\x1b\x1b\x1b\s*$/ms", $config_block, $match, PREG_SET_ORDER)) {
             for ($i = 0; $i < count($match); $i++) {
-                $this->_set_config_var($vars, trim($match[$i][1]), $match[$i][2], false);
+                $this->_set_config_var($vars, trim($match[$i][1]), $triple_quotes[$match[$i][2]], false);
             }
-            $config_block = preg_replace("/^[^=\n]+=\s*\"{3}.*?\"{3}\s*$/ms", "", $config_block);
+            $config_block = preg_replace("/^[^=\n]+=\s*\x1b\x1b\x1b\d+\x1b\x1b\x1b\s*$/ms", "", $config_block);
         }
 
 

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.