$tmp .= "[$section]\n";
foreach($values as $key => $val){
if(is_array($val)){
- foreach($val as $k =>$v){
+ foreach($val as $k => $v) {
+ $v = $this->escapeINIVal($v);
$tmp .= "{$key}[$k] = \"$v\"\n";
}
} else {
+ $val = $this->escapeINIVal($val);
$tmp .= "$key = \"$val\"\n";
}
}
return $result;
}
+ /**
+ * Escape text written to INI-style file.
+ *
+ * @access private
+ * @param string $value text to escape
+ * @return string escaped text
+ */
+ private function escapeINIVal($value) {
+ $esc_value = str_replace('"', '\"', $value);
+ return $esc_value;
+ }
+
/**
* Parse INI-style configuration file.
*