fix(files_sharing): reject custom share tokens longer than the db column#61630
Conversation
joshtrichards
left a comment
There was a problem hiding this comment.
Looks good! Just a minor nitpick, which is non-blocking. My other two comments can be handled in a follow-up PR -- or skipped entirely -- unless you prefer to include them now.
|
/backport to stable34 |
|
/backport to stable33 |
efdc19f to
1e2dce6
Compare
…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>
Co-authored-by: Josh <josh.t.richards@gmail.com> Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1e2dce6 to
a40a092
Compare
|
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
…length The custom share link token input accepted arbitrarily long values, while the server (and the oc_share.token database column) only allows 32 characters. Users learned about the limit only after submitting the form and reading the error toast. Set the maxlength attribute on the token input matching ShareAPIController::TOKEN_MAX_LENGTH and mention the length and character constraints in the helper text, so the limit is communicated before saving instead of after a failed request. Related: nextcloud#61416, follow-up to nextcloud#61630 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Assisted-by: ClaudeCode:claude-fable-5 Signed-off-by: MiMoHo <37556964+MiMoHo@users.noreply.github.com>
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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.
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.