summaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
authoricewind1991 <icewind1991@gmail.com>2013-05-31 14:00:02 -0700
committericewind1991 <icewind1991@gmail.com>2013-05-31 14:00:02 -0700
commit94a6622bcd3c4a77aa2af8fd09920f8ac1e0245f (patch)
treef95ad6e96bcaa8908b911ed326de8700c3b1a8ae /lib/files
parent1656cc2e7c70288e705dc47db9c618149ab79111 (diff)
parentadcafbde34b8f4c75dbf724e929766a1f7d964d4 (diff)
downloadnextcloud-server-94a6622bcd3c4a77aa2af8fd09920f8ac1e0245f.tar.gz
nextcloud-server-94a6622bcd3c4a77aa2af8fd09920f8ac1e0245f.zip
Merge pull request #3459 from owncloud/fix_for_2377
fix problems with german "Umlaut" in folder name
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/cache/cache.php41
-rw-r--r--lib/files/filesystem.php5
2 files changed, 43 insertions, 3 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 0210d5a73f1..cae2e63e4dc 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -100,6 +100,9 @@ class Cache {
*/
public function get($file) {
if (is_string($file) or $file == '') {
+ // normalize file
+ $file = $this->normalize($file);
+
$where = 'WHERE `storage` = ? AND `path_hash` = ?';
$params = array($this->getNumericStorageId(), md5($file));
} else { //file id
@@ -179,6 +182,9 @@ class Cache {
$this->update($id, $data);
return $id;
} else {
+ // normalize file
+ $file = $this->normalize($file);
+
if (isset($this->partial[$file])) { //add any saved partial data
$data = array_merge($this->partial[$file], $data);
unset($this->partial[$file]);
@@ -220,6 +226,17 @@ class Cache {
* @param array $data
*/
public function update($id, array $data) {
+
+ if(isset($data['path'])) {
+ // normalize path
+ $data['path'] = $this->normalize($data['path']);
+ }
+
+ if(isset($data['name'])) {
+ // normalize path
+ $data['name'] = $this->normalize($data['name']);
+ }
+
list($queryParts, $params) = $this->buildParts($data);
$params[] = $id;
@@ -267,6 +284,9 @@ class Cache {
* @return int
*/
public function getId($file) {
+ // normalize file
+ $file = $this->normalize($file);
+
$pathHash = md5($file);
$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
@@ -334,6 +354,10 @@ class Cache {
* @param string $target
*/
public function move($source, $target) {
+ // normalize source and target
+ $source = $this->normalize($source);
+ $target = $this->normalize($target);
+
$sourceData = $this->get($source);
$sourceId = $sourceData['fileid'];
$newParentId = $this->getParentId($target);
@@ -374,6 +398,9 @@ class Cache {
* @return int, Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE
*/
public function getStatus($file) {
+ // normalize file
+ $file = $this->normalize($file);
+
$pathHash = md5($file);
$query = \OC_DB::prepare('SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
$result = $query->execute(array($this->getNumericStorageId(), $pathHash));
@@ -402,6 +429,10 @@ class Cache {
* @return array of file data
*/
public function search($pattern) {
+
+ // normalize pattern
+ $pattern = $this->normalize($pattern);
+
$query = \OC_DB::prepare('
SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `storage` = ?'
@@ -551,4 +582,14 @@ class Cache {
return null;
}
}
+
+ /**
+ * normalize the given path
+ * @param $path
+ * @return string
+ */
+ public function normalize($path) {
+
+ return \OC_Util::normalizeUnicode($path);
+ }
}
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index b10625e20de..02cce001b48 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -631,9 +631,8 @@ class Filesystem {
$path = substr($path, 0, -1);
}
//normalize unicode if possible
- if (class_exists('Normalizer')) {
- $path = \Normalizer::normalize($path);
- }
+ $path = \OC_Util::normalizeUnicode($path);
+
return $path;
}