codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
385 stars 69 forks source link

Post edit comment length is not validated at all #1258

Closed Oaphi closed 8 months ago

Oaphi commented 9 months ago

Describe the bug

Length of edit comments (both privileged edits and suggested edits) is not validated neither client-side nor server-side. As a result, editors can submit up to 65 535 (privileged edits) or 255 (suggested edits) characters.

Additionally, because there are no validations, if a user attempts to submit more characters than the limits mentioned above, they'll get a raw query error due to the DB rejecting the value for the comment column.

To Reproduce

Steps to reproduce the behavior:

  1. Log in as an unprivileged user.
  2. Make an edit suggestion to any post.
  3. Include more than 255 characters in the comment field.
  4. Observe the raw query error.

There definitely needs to be some limit (and an accompanying character counter client-side), although the exact limit is up for debate (it can be made configurable, but it still leaves us with the question of what would be the default). I propose a soft cap of 150 characters (similar to commit messages) with a somewhat higher hard cap (200 or 255).