From 09f19e675f3396a8a0f26fecd9b0501d19a4999f Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 25 Sep 2008 17:20:40 +0000 Subject: - Fix problem with non-ascii attachment names in Mail_mime (#1485267, #1485096) --- program/lib/Mail/mime.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'program/lib/Mail/mime.php') diff --git a/program/lib/Mail/mime.php b/program/lib/Mail/mime.php index 92c797b28..7641b0c9b 100644 --- a/program/lib/Mail/mime.php +++ b/program/lib/Mail/mime.php @@ -350,7 +350,7 @@ class Mail_mime $err = PEAR::raiseError($msg); return $err; } - $filename = substr('s_'.basename($filename), 2); + $filename = $this->_basename($filename); if (PEAR::isError($filedata)) { return $filedata; } @@ -667,7 +667,7 @@ class Mail_mime $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody); $this->_html_images[$key]['name'] = - substr(basename('s_'.$this->_html_images[$key]['name']), 2); + $this->_basename($this->_html_images[$key]['name']); } } @@ -1114,6 +1114,21 @@ class Mail_mime } } - + /** + * Get file's basename (locale independent) + * + * @param string Filename + * + * @return string Basename + * @access private + */ + function _basename($filename) + { + // basename() is not unicode safe and locale dependent + if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) + return preg_replace('/^.*[\\\\\\/]/', '', $filename); + else + return preg_replace('/^.*[\/]/', '', $filename); + } } // End of class -- cgit v1.2.3