[stable32] fix(files_sharing): reject custom share tokens longer than the db column#61827
Open
MiMoHo wants to merge 2 commits into
Open
[stable32] fix(files_sharing): reject custom share tokens longer than the db column#61827MiMoHo wants to merge 2 commits into
MiMoHo wants to merge 2 commits into
Conversation
…se column validateToken() only checked for an empty string and an invalid character set, not length. A custom share token longer than 32 characters passes validation, then fails at the database layer (oc_share.token is varchar(32)) with a raw SQL exception instead of a clear validation error. Add a max-length check matching the column size, and mention the limit in the existing error message. Assisted-by: ClaudeCode:claude-sonnet-4-6 Signed-off-by: Amit Mishra <amit.mishra.eee21@itbhu.ac.in> (cherry picked from commit 7421ea7)
Co-authored-by: Josh <josh.t.richards@gmail.com> Signed-off-by: Carl Schwan <carl@carlschwan.eu> (cherry picked from commit a40a092)
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.
Backport of #61630 to stable32 (fixes #61416 there).
stable32 still ships the custom share link token feature but not the length validation:
validateToken()only checks for an empty string and the character set, so a token longer than 32 characters passes validation and then fails at the database layer (oc_share.tokenis varchar(32)) with the generic "Failed to update share." instead of a clear validation message.The fix is already merged to master (#61630) and stable34 (#61676); the stable33 backport is pending in #61675. stable32 was never requested, so this closes the gap for the remaining supported branch.
Both original commits are cherry-picked with authorship and sign-offs preserved (
-xannotations included). One adaptation was needed: the test uses the fully qualified#[\PHPUnit\Framework\Attributes\DataProvider]attribute, matching the conventions in stable32'sShareAPIControllerTest.php(the bareDataProviderimport and the surroundingmockTalkControllerhelper from master do not exist on this branch).🤖 Generated with Claude Code