summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-09-25 17:20:40 +0000
committeralecpl <alec@alec.pl>2008-09-25 17:20:40 +0000
commit09f19e675f3396a8a0f26fecd9b0501d19a4999f (patch)
treec338930acf9e04a3e1cd79fabf582a77b4825aa7 /program/lib
parent47c9ccbf6f2ffc344a5e85eefe4a9b9ba2c1b1ba (diff)
- Fix problem with non-ascii attachment names in Mail_mime (#1485267, #1485096)
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Mail/mime.php21
1 files changed, 18 insertions, 3 deletions
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