Permalink
Browse files

MDL-25472 support non-standard dir separators in zip archives and oth…

…er anomalies
  • Loading branch information...
1 parent 8d33799 commit 320e50b78383ce1e7278565a041344312b8de3b1 @skodak skodak committed Dec 8, 2010
Showing with 7 additions and 9 deletions.
  1. +7 −9 lib/filestorage/file_archive.php
@@ -161,20 +161,18 @@ protected function mangle_pathname($localname) {
* please note that it may fail really badly.
* The resulting file name is cleaned.
*
- * @param string $localname in another encoding
+ * @param string $localname in $this->encoding
* @return string in utf-8
*/
protected function unmangle_pathname($localname) {
- if ($this->encoding === 'utf-8') {
- return $localname;
- }
- $textlib = textlib_get_instance();
+ $result = str_replace('\\', '/', $localname); // no MS \ separators
+ $result = ltrim($result, '/'); // no leading /
- $result = $textlib->convert($localname, $this->encoding, 'utf-8');
- $result = clean_param($result, PARAM_PATH);
- $result = ltrim($result); // no leading /
+ if ($this->encoding !== 'utf-8') {
+ $result = textlib_get_instance()->convert($result, $this->encoding, 'utf-8');
+ }
- return $result;
+ return clean_param($result, PARAM_PATH);
}
/**

0 comments on commit 320e50b

Please sign in to comment.