fix: catch OCSForbiddenException in public page search#2346
Open
saschabuehrle wants to merge 1 commit intonextcloud:mainfrom
Open
fix: catch OCSForbiddenException in public page search#2346saschabuehrle wants to merge 1 commit intonextcloud:mainfrom
saschabuehrle wants to merge 1 commit intonextcloud:mainfrom
Conversation
When anonymous users search through a public page share link, checkPageShareAccess() throws OCSForbiddenException instead of NotPermittedException. This change catches both exception types to prevent the API from crashing with HTTP 403 Forbidden. Fixes nextcloud#2345
Collaborator
|
Thanks a lot for your contribution. Makes sense to me. I'll take a close look at the code paths later to properly review it. Workflow results
|
|
Sorry to interrupt, I wanted to let you know that this PR is most probably entirely AI-generated, including replies to your comments. Just see the batch of PRs they opened recently to form your own opinion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Issue #2345 — When anonymous users search through a public page share link, the search scans the entire Collective but attempts to filter unauthorized results using checkPageShareAccess(). However, this function throws
OCSForbiddenExceptioninstead of the expectedNotPermittedException, causing the exception to bypass the catch block and crash the API with HTTP 403 Forbidden.Fix
This PR updates the exception handling in the
contentSearchmethod to catch bothNotPermittedExceptionandOCSForbiddenException. This ensures that unauthorized search results are properly filtered out instead of causing the entire API call to fail.Testing
The fix ensures that anonymous users can search through public page shares without encountering HTTP 403 errors when some results are outside their access permissions.
Greetings, saschabuehrle