]> source.dussan.org Git - nextcloud-server.git/commitdiff
Correct OC_Config writer. Use var_export (has support for array,...)
authorBrice Maron <brice@bmaron.net>
Fri, 22 Jun 2012 10:44:17 +0000 (12:44 +0200)
committerBrice Maron <brice@bmaron.net>
Fri, 22 Jun 2012 10:46:21 +0000 (12:46 +0200)
lib/config.php

index 9279549b1bbdcbd6dba11bd5a2b24bba281dfd96..65f9fdc06baf13b74bfa55c2813cd0d0dfe58bde 100644 (file)
@@ -152,23 +152,12 @@ class OC_Config{
         *
         * Saves the config to the config file.
         *
-        * Known flaws: Strings are not escaped properly
         */
        public static function writeData(){
                // Create a php file ...
-               $content = "<?php\n\$CONFIG = array(\n";
-
-               foreach( self::$cache as $key => $value ){
-                       if( is_bool( $value )){
-                               $value = $value ? 'true' : 'false';
-                               $content .= "\"$key\" => $value,\n";
-                       }
-                       else{
-                               $value = str_replace( "'", "\\'", $value );
-                               $content .= "\"$key\" => '$value',\n";
-                       }
-               }
-               $content .= ");\n?>\n";
+               $content = "<?php\n\$CONFIG = ";
+               $content .= var_export(self::$cache, true);
+               $content .= ";\n?>\n";
 
                $filename = OC::$SERVERROOT."/config/config.php";
                // Write the file