Skip to content

fix(files_sharing): reject custom share tokens longer than the databa…#61630

Open
amitmishra11 wants to merge 1 commit into
nextcloud:masterfrom
amitmishra11:fix/share-token-length-validation
Open

fix(files_sharing): reject custom share tokens longer than the databa…#61630
amitmishra11 wants to merge 1 commit into
nextcloud:masterfrom
amitmishra11:fix/share-token-length-validation

Conversation

@amitmishra11

Copy link
Copy Markdown

validateToken() in ShareAPIController only checked that a custom share token was non-empty and matched the allowed character set, but never checked its length. The oc_share.token database column is varchar(32), so a longer token currently passes validation and then fails at the database layer with a raw, unhelpful SQL error instead of a clean validation message.

This adds a max-length check matching the column size and updates the error message to mention the limit.

  • Testing

Added a test for validateToken() covering the empty, valid, and invalid-character cases plus the new 32/33-character boundary (32 should pass, 33 should fail).

This PR was prepared with AI assistance (Claude Code); I reviewed the change before submitting it.

…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>
@amitmishra11 amitmishra11 requested a review from a team as a code owner June 27, 2026 15:45
@amitmishra11 amitmishra11 requested review from Altahrim, come-nc, icewind1991 and provokateurin and removed request for a team June 27, 2026 15:45
@susnux susnux added bug 3. to review Waiting for reviews feature: sharing sharing AI assisted community pull requests from community and removed sharing labels Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted bug community pull requests from community feature: sharing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: public shares: Over-length custom token: Fails silently

2 participants