Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit d69034f

Browse files
committed
Fix VarsFiltering issues: when PARENT_REPOSITORY_OPTION do not go further. Do not filter repository display anymore for sec reasons.
1 parent 79e0359 commit d69034f

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

core/src/core/src/pydio/Core/Utils/Vars/VarsFilter.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ class VarsFilter
5151
*/
5252
public static function filter($value, ContextInterface $ctx)
5353
{
54+
// If AJXP_PARENT_OPTION, resolve and return directly, do not filter the real value.
55+
if(is_string($value) && preg_match("/AJXP_PARENT_OPTION:([\w_-]*):/", $value, $matches)){
56+
$repoObject = $ctx->getRepository();
57+
$parentRepository = $repoObject->getParentRepository();
58+
if(empty($parentRepository)){
59+
throw new PydioException("Cannot resolve ".$matches[0]." without parent workspace");
60+
}
61+
$parentOwner = $ctx->getRepository()->getOwner();
62+
$parentContext = Context::contextWithObjects(null, $parentRepository);
63+
$parentContext->setUserId($parentOwner);
64+
$parentPath = rtrim($parentRepository->getContextOption($parentContext, $matches[1]), "/");
65+
$value = str_replace($matches[0], $parentPath, $value);
66+
return $value;
67+
}
68+
5469
if (is_string($value) && strpos($value, "AJXP_USER")!==false) {
5570
if (UsersService::usersEnabled()) {
5671
if(!$ctx->hasUser()){
@@ -85,18 +100,6 @@ public static function filter($value, ContextInterface $ctx)
85100
if (is_string($value) && strstr($value, "AJXP_WORKSPACE_SLUG") !== false) {
86101
$value = rtrim(str_replace("AJXP_WORKSPACE_SLUG", $ctx->getRepository()->getSlug(), $value), "/");
87102
}
88-
if(is_string($value) && preg_match("/AJXP_PARENT_OPTION:([\w_-]*):/", $value, $matches)){
89-
$repoObject = $ctx->getRepository();
90-
$parentRepository = $repoObject->getParentRepository();
91-
if(empty($parentRepository)){
92-
throw new PydioException("Cannot resolve ".$matches[0]." without parent workspace");
93-
}
94-
$parentOwner = $ctx->getRepository()->getOwner();
95-
$parentContext = Context::contextWithObjects(null, $parentRepository);
96-
$parentContext->setUserId($parentOwner);
97-
$parentPath = rtrim($parentRepository->getContextOption($parentContext, $matches[1]), "/");
98-
$value = str_replace($matches[0], $parentPath, $value);
99-
}
100103

101104
$tab = array(&$value, $ctx);
102105
Controller::applyIncludeHook("vars.filter", $tab);

core/src/plugins/core.access/src/Model/Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function getDisplay()
425425
return $mess[$this->displayStringId];
426426
}
427427
}
428-
return VarsFilter::filter($this->display, Context::emptyContext());
428+
return $this->display;
429429
}
430430

431431
/**

0 commit comments

Comments
 (0)