Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(dav): drop unwanted RemoteException class #46952

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions public.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,33 @@ function resolveService(string $service): string {
// this policy with a softer one if debug mode is enabled.
header("Content-Security-Policy: default-src 'none';");

// Check if Nextcloud is in maintenance mode
if (\OCP\Util::needUpgrade()) {
// since the behavior of apps or remotes are unpredictable during
// an upgrade, return a 503 directly
throw new RemoteException('Service unavailable', 503);
throw new \Exception('Service unavailable', 503);
}

$request = \OC::$server->getRequest();
$pathInfo = $request->getPathInfo();
if ($pathInfo === false || $pathInfo === '') {
throw new RemoteException('Path not found', 404);
throw new \Exception('Path not found', 404);
}

// Extract the service from the path
if (!$pos = strpos($pathInfo, '/', 1)) {
$pos = strlen($pathInfo);
}
$service = substr($pathInfo, 1, $pos - 1);

// Resolve the service to a file
$file = resolveService($service);

if (!$file) {
throw new RemoteException('Path not found', 404);
throw new \Exception('Path not found', 404);
}

// Extract the app from the service file
$file = ltrim($file, '/');

$parts = explode('/', $file, 2);
$app = $parts[0];

Expand All @@ -91,9 +94,12 @@ function resolveService(string $service): string {
OC_App::loadApps(['extended_authentication']);
OC_App::loadApps(['filesystem', 'logging']);

// Check if the app is enabled
if (!\OC::$server->getAppManager()->isInstalled($app)) {
throw new RemoteException('App not installed: ' . $app);
throw new \Exception('App not installed: ' . $app);
}

// Load the app
OC_App::loadApp($app);
OC_User::setIncognitoMode(true);

Expand Down
2 changes: 1 addition & 1 deletion remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* Dummy exception class to be use locally to identify certain conditions
* Will not be logged to avoid DoS
*/
class RemoteException extends Exception {
class RemoteException extends \Exception {
}

/**
Expand Down
Loading