Remove duplicate '/' from target when searching for source
This commit is contained in:
parent
010920ad08
commit
163c490c92
|
@ -128,8 +128,9 @@ class OC_SHARE {
|
||||||
* @return source path
|
* @return source path
|
||||||
*/
|
*/
|
||||||
public static function getSource($target) {
|
public static function getSource($target) {
|
||||||
// Remove any trailing '/'
|
// Remove any duplicate or trailing '/'
|
||||||
$target = rtrim($target, "/");
|
$target = rtrim($target, "/");
|
||||||
|
$target = preg_replace('{(/)\1+}', "/", $target);
|
||||||
$query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1");
|
$query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1");
|
||||||
$result = $query->execute(array($target, $_SESSION['user_id']))->fetchAll();
|
$result = $query->execute(array($target, $_SESSION['user_id']))->fetchAll();
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
|
@ -141,8 +142,9 @@ class OC_SHARE {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getParentFolders($path, $isSource = true) {
|
public static function getParentFolders($path, $isSource = true) {
|
||||||
// Remove any trailing '/'
|
// Remove any duplicate or trailing '/'
|
||||||
$path = rtrim($path, "/");
|
$path = rtrim($path, "/");
|
||||||
|
$path = preg_replace('{(/)\1+}', "/", $path);
|
||||||
if ($isSource) {
|
if ($isSource) {
|
||||||
$query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? LIMIT 1");
|
$query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? LIMIT 1");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue