From c21d6d713e0320b7b61bff1fa0e05bbd250455bb Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 03 Nov 2008 03:01:18 -0500
Subject: [PATCH] Don't use addslashes() which could produce unexpected results when magic_quotes_sybase is on

---
 program/include/main.inc   |    4 +++-
 program/steps/mail/get.inc |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 4ed25af..43a3549 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -347,6 +347,8 @@
       }
 
     $xml_rep_table['"'] = '&quot;';
+    $js_rep_table['"'] = '\\"';
+    $js_rep_table["'"] = "\\'";
     }
 
   // encode for XML
@@ -359,7 +361,7 @@
     if ($charset!='UTF-8')
       $str = rcube_charset_convert($str, RCMAIL_CHARSET,$charset);
       
-    return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), addslashes(strtr($str, $js_rep_table)));
+    return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table));
     }
 
   // no encoding given -> return original string
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index fc3ee83..2d51ffc 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -90,7 +90,7 @@
       
       $filename = $part->filename ? $part->filename : ($MESSAGE->subject ? $MESSAGE->subject : 'roundcube') . '.'.$ctype_secondary;
       $filename = abbreviate_string($part->filename, 55);
-      $filename = $browser->ie ? rawurlencode($filename) : addslashes($filename);
+      $filename = $browser->ie ? rawurlencode($filename) : addcslashes($filename, '"');
       $disposition = !empty($_GET['_download']) ? 'attachment' : 'inline';
       
       header("Content-Disposition: $disposition; filename=\"$filename\"");

--
Gitblit v1.9.1