diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/NavigationManager.php | 19 | ||||
-rw-r--r-- | lib/private/Preview/Watcher.php | 3 | ||||
-rw-r--r-- | lib/private/Preview/WatcherConnector.php | 32 | ||||
-rw-r--r-- | lib/private/Security/Normalizer/IpAddress.php | 9 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | lib/private/Template/JSResourceLocator.php | 2 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 5 |
7 files changed, 37 insertions, 36 deletions
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index c2125bc6f8a..fb0795376bb 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -77,7 +77,7 @@ class NavigationManager implements INavigationManager { $this->closureEntries[] = $entry; return; } - $this->init(); + $this->init(false); $id = $entry['id']; @@ -123,10 +123,6 @@ class NavigationManager implements INavigationManager { */ public function getAll(string $type = 'link'): array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; $result = $this->entries; if ($type !== 'all') { @@ -212,7 +208,13 @@ class NavigationManager implements INavigationManager { return $this->activeEntry; } - private function init() { + private function init(bool $resolveClosures = true): void { + if ($resolveClosures) { + while ($c = array_pop($this->closureEntries)) { + $this->add($c()); + } + } + if ($this->init) { return; } @@ -420,11 +422,6 @@ class NavigationManager implements INavigationManager { public function get(string $id): ?array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; - return $this->entries[$id]; } diff --git a/lib/private/Preview/Watcher.php b/lib/private/Preview/Watcher.php index abddd7b5acb..21f040d8342 100644 --- a/lib/private/Preview/Watcher.php +++ b/lib/private/Preview/Watcher.php @@ -8,6 +8,7 @@ declare(strict_types=1); */ namespace OC\Preview; +use OCP\Files\FileInfo; use OCP\Files\Folder; use OCP\Files\IAppData; use OCP\Files\Node; @@ -37,7 +38,7 @@ class Watcher { $this->deleteNode($node); } - protected function deleteNode(Node $node) { + protected function deleteNode(FileInfo $node) { // We only handle files if ($node instanceof Folder) { return; diff --git a/lib/private/Preview/WatcherConnector.php b/lib/private/Preview/WatcherConnector.php index ae2a136ca78..c34dd1dde4d 100644 --- a/lib/private/Preview/WatcherConnector.php +++ b/lib/private/Preview/WatcherConnector.php @@ -9,43 +9,33 @@ declare(strict_types=1); namespace OC\Preview; use OC\SystemConfig; +use OCA\Files_Versions\Events\VersionRestoredEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\Node; class WatcherConnector { - /** @var IRootFolder */ - private $root; - - /** @var SystemConfig */ - private $config; - - /** - * WatcherConnector constructor. - * - * @param IRootFolder $root - * @param SystemConfig $config - */ - public function __construct(IRootFolder $root, - SystemConfig $config) { - $this->root = $root; - $this->config = $config; + public function __construct( + private IRootFolder $root, + private SystemConfig $config, + private IEventDispatcher $dispatcher, + ) { } - /** - * @return Watcher - */ private function getWatcher(): Watcher { return \OCP\Server::get(Watcher::class); } - public function connectWatcher() { + public function connectWatcher(): void { // Do not connect if we are not setup yet! if ($this->config->getValue('instanceid', null) !== null) { $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { $this->getWatcher()->postWrite($node); }); - \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); + $this->dispatcher->addListener(VersionRestoredEvent::class, function (VersionRestoredEvent $event) { + $this->getWatcher()->versionRollback(['node' => $event->getVersion()->getSourceFile()]); + }); } } } diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index b3793685a24..4d33a7bd632 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -42,8 +42,15 @@ class IpAddress { $maskSize = min(64, $config->getSystemValueInt('security.ipv6_normalized_subnet_size', 56)); $maskSize = max(32, $maskSize); if (PHP_INT_SIZE === 4) { + if ($maskSize === 64) { + $value = -1; + } elseif ($maskSize === 63) { + $value = PHP_INT_MAX; + } else { + $value = (1 << $maskSize - 32) - 1; + } // as long as we support 32bit PHP we cannot use the `P` pack formatter (and not overflow 32bit integer) - $mask = pack('VVVV', 0xFFFF, $maskSize === 64 ? 0xFFFF : ((1 << $maskSize - 32) - 1), 0, 0); + $mask = pack('VVVV', -1, $value, 0, 0); } else { $mask = pack('VVP', (1 << 32) - 1, (1 << $maskSize - 32) - 1, 0); } diff --git a/lib/private/Server.php b/lib/private/Server.php index 4d79fefd261..545ceacbe81 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -411,7 +411,8 @@ class Server extends ServerContainer implements IServerContainer { $previewConnector = new \OC\Preview\WatcherConnector( $root, - $c->get(SystemConfig::class) + $c->get(SystemConfig::class), + $this->get(IEventDispatcher::class) ); $previewConnector->connectWatcher(); diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index aad999f939a..a6d2d13a2ad 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -69,7 +69,7 @@ class JSResourceLocator extends ResourceLocator { || $this->appendScriptIfExist($this->serverroot, "dist/$app-$scriptName") || $this->appendScriptIfExist($appRoot, $script, $appWebRoot) || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script . '.json') - || $this->cacheAndAppendCombineJsonIfExist($appRoot, $script . '.json', $appWebRoot) + || $this->cacheAndAppendCombineJsonIfExist($appRoot, $script . '.json', $app) || $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") diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index ad12fae5144..c78ecac0903 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -304,6 +304,11 @@ class URLGenerator implements IURLGenerator { if ($href === '') { throw new \InvalidArgumentException('Default navigation entry is missing href: ' . $entryId); } + + if (str_starts_with($href, $this->getBaseUrl())) { + return $href; + } + if (str_starts_with($href, '/index.php/') && ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true')) { $href = substr($href, 10); } |