[RCD] attaching files with russian filenames strips leading Cyrillic characters from the file

A.L.E.C alec at alec.pl
Tue Sep 23 09:53:03 CEST 2008


Dennis P. Nikolaenko wrote:
> Hello,
> Please consider integrating the patch in ticket #1485267
>   

maybe in this way?:

--- mime.old	2008-09-21 10:40:36.000000000 +0200
+++ mime.php	2008-09-23 09:22:42.221738855 +0200
@@ -350,7 +350,7 @@
             $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 @@
 
                 $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,20 @@
         }
     }
 
-    
+    /**
+     * Get file's basename (locale independent) 
+     *
+     * @param string Filename
+     *
+     * @return string Basename
+     * @access private
+     */
+    function _basename($filename)
+    {
+	if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware'))
+	    return preg_replace('/^.*[\\\\\\/]/', '', $filename);
+	else
+	    return preg_replace('/^.*[\/]/', '', $filename);
+    }
 
 } // End of class


-- 
Aleksander 'A.L.E.C' Machniak http://alec.pl gg:2275252
LAN Management System Developer http://lms.org.pl
Roundcube Webmail Project Developer http://roundcube.net
_______________________________________________
List info: http://lists.roundcube.net/dev/



More information about the Dev mailing list