aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Template
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-03-15 13:03:34 +0100
committerGitHub <noreply@github.com>2024-03-15 13:03:34 +0100
commit9338ef36ded767f2c35b7ec575b351859420ed09 (patch)
tree65c53c6a36f300859dc22b2d423275bcf2911367 /lib/private/Template
parent6b09a79227a5dc98aa4620c6e5e15b610a06c806 (diff)
parentdf1cd1ba7e6e1f6e66a2b3229b5c082f1b81162e (diff)
downloadnextcloud-server-9338ef36ded767f2c35b7ec575b351859420ed09.tar.gz
nextcloud-server-9338ef36ded767f2c35b7ec575b351859420ed09.zip
Merge branch 'master' into refactor/OC-Server-getShareManager
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'lib/private/Template')
-rw-r--r--lib/private/Template/JSCombiner.php8
-rw-r--r--lib/private/Template/JSConfigHelper.php25
-rw-r--r--lib/private/Template/JSResourceLocator.php55
3 files changed, 38 insertions, 50 deletions
diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php
index b87829360d5..fad69a76ae0 100644
--- a/lib/private/Template/JSCombiner.php
+++ b/lib/private/Template/JSCombiner.php
@@ -55,10 +55,10 @@ class JSCombiner {
private $cacheFactory;
public function __construct(IAppData $appData,
- IURLGenerator $urlGenerator,
- ICacheFactory $cacheFactory,
- SystemConfig $config,
- LoggerInterface $logger) {
+ IURLGenerator $urlGenerator,
+ ICacheFactory $cacheFactory,
+ SystemConfig $config,
+ LoggerInterface $logger) {
$this->appData = $appData;
$this->urlGenerator = $urlGenerator;
$this->cacheFactory = $cacheFactory;
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index 9cf0838e43a..d2cd536fa9f 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -45,9 +45,9 @@ use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IInitialStateService;
use OCP\IL10N;
+use OCP\ILogger;
use OCP\ISession;
use OCP\IURLGenerator;
-use OCP\ILogger;
use OCP\IUser;
use OCP\Share\IManager as IShareManager;
use OCP\User\Backend\IPasswordConfirmationBackend;
@@ -70,16 +70,16 @@ class JSConfigHelper {
private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true];
public function __construct(IL10N $l,
- Defaults $defaults,
- IAppManager $appManager,
- ISession $session,
- ?IUser $currentUser,
- IConfig $config,
- IGroupManager $groupManager,
- IniGetWrapper $iniWrapper,
- IURLGenerator $urlGenerator,
- CapabilitiesManager $capabilitiesManager,
- IInitialStateService $initialStateService) {
+ Defaults $defaults,
+ IAppManager $appManager,
+ ISession $session,
+ ?IUser $currentUser,
+ IConfig $config,
+ IGroupManager $groupManager,
+ IniGetWrapper $iniWrapper,
+ IURLGenerator $urlGenerator,
+ CapabilitiesManager $capabilitiesManager,
+ IInitialStateService $initialStateService) {
$this->l = $l;
$this->defaults = $defaults;
$this->appManager = $appManager;
@@ -180,7 +180,8 @@ class JSConfigHelper {
'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)),
'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0),
'version' => implode('.', Util::getVersion()),
- 'versionstring' => \OC_Util::getVersionString()
+ 'versionstring' => \OC_Util::getVersionString(),
+ 'enable_non-accessible_features' => $this->config->getSystemValueBool('enable_non-accessible_features', true),
];
$array = [
diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php
index b283f0b610f..c73b3efe997 100644
--- a/lib/private/Template/JSResourceLocator.php
+++ b/lib/private/Template/JSResourceLocator.php
@@ -51,6 +51,22 @@ class JSResourceLocator extends ResourceLocator {
// Extracting the appId and the script file name
$app = substr($script, 0, strpos($script, '/'));
$scriptName = basename($script);
+ // Get the app root path
+ $appRoot = $this->serverroot . 'apps/';
+ $appWebRoot = null;
+ try {
+ // We need the dir name as getAppPath appends the appid
+ $appRoot = dirname($this->appManager->getAppPath($app));
+ // Only do this if $app_path is set, because an empty argument to realpath gets turned into cwd.
+ if ($appRoot) {
+ // Handle symlinks
+ $appRoot = realpath($appRoot);
+ }
+ // Get the app webroot
+ $appWebRoot = dirname($this->appManager->getAppWebPath($app));
+ } catch (AppPathNotFoundException $e) {
+ // ignore
+ }
if (str_contains($script, '/l10n/')) {
// For language files we try to load them all, so themes can overwrite
@@ -60,7 +76,7 @@ class JSResourceLocator extends ResourceLocator {
$found += $this->appendScriptIfExist($this->serverroot, $theme_dir.'core/'.$script);
$found += $this->appendScriptIfExist($this->serverroot, $script);
$found += $this->appendScriptIfExist($this->serverroot, $theme_dir.$script);
- $found += $this->appendScriptIfExist($this->serverroot, 'apps/'.$script);
+ $found += $this->appendScriptIfExist($appRoot, $script, $appWebRoot);
$found += $this->appendScriptIfExist($this->serverroot, $theme_dir.'apps/'.$script);
if ($found) {
@@ -71,8 +87,9 @@ class JSResourceLocator extends ResourceLocator {
|| $this->appendScriptIfExist($this->serverroot, $script)
|| $this->appendScriptIfExist($this->serverroot, $theme_dir."dist/$app-$scriptName")
|| $this->appendScriptIfExist($this->serverroot, "dist/$app-$scriptName")
- || $this->appendScriptIfExist($this->serverroot, 'apps/'.$script)
+ || $this->appendScriptIfExist($appRoot, $script, $appWebRoot)
|| $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json')
+ || $this->cacheAndAppendCombineJsonIfExist($appRoot, $script.'.json', $appWebRoot)
|| $this->appendScriptIfExist($this->serverroot, $theme_dir.'core/'.$script)
|| $this->appendScriptIfExist($this->serverroot, 'core/'.$script)
|| (strpos($scriptName, '/') === -1 && ($this->appendScriptIfExist($this->serverroot, $theme_dir."dist/core-$scriptName")
@@ -82,43 +99,13 @@ class JSResourceLocator extends ResourceLocator {
return;
}
- $script = substr($script, strpos($script, '/') + 1);
- $app_url = null;
-
- try {
- $app_url = $this->appManager->getAppWebPath($app);
- } catch (AppPathNotFoundException) {
- // pass
- }
-
- try {
- $app_path = $this->appManager->getAppPath($app);
-
- // Account for the possibility of having symlinks in app path. Only
- // do this if $app_path is set, because an empty argument to realpath
- // gets turned into cwd.
- $app_path = realpath($app_path);
-
- // check combined files
- if (!str_starts_with($script, 'l10n/') && $this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) {
- return;
- }
-
- // fallback to plain file location
- if ($this->appendScriptIfExist($app_path, $script, $app_url)) {
- return;
- }
- } catch (AppPathNotFoundException) {
- // pass (general error handling happens below)
- }
-
// missing translations files will be ignored
- if (str_starts_with($script, 'l10n/')) {
+ if (str_contains($script, '/l10n/')) {
return;
}
$this->logger->error('Could not find resource {resource} to load', [
- 'resource' => $app . '/' . $script . '.js',
+ 'resource' => $script . '.js',
'app' => 'jsresourceloader',
]);
}