Fix quote_imap, the ereg pattern wasn't always interpreted right
[squirrelmail.git] / functions / strings.php
index 01454742ee109a5458f277fae3ba9b3e0fb07227..4ff54b898bfeb95e145ed5deb259da559bf41aa0 100644 (file)
@@ -458,7 +458,7 @@ function GenerateRandomString($size, $chars, $flags = 0) {
  * @return string the escaped string
  */
 function quoteimap($str) {
-    return ereg_replace('(["\\])', '\\\\1', $str);
+    return preg_replace("/([\"\\\\])/", "\\\\$1", $str);
 }
 
 /**
@@ -541,5 +541,21 @@ function sm_print_r() {
     print '</pre>';
 }
 
+/**
+ * version of fwrite which checks for failure
+ */
+function sq_fwrite($fp, $string) {
+       // write to file
+       $count = @fwrite($fp,$string);
+       // the number of bytes written should be the length of the string
+       if($count != strlen($string)) {
+               return FALSE;
+       }
+
+       return $count;
+}
+
+
+
 $PHP_SELF = php_self();
 ?>