Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Post-content validation max-value #13

Open
wolfgang-demeter opened this issue Jan 9, 2022 · 1 comment
Open

Increase Post-content validation max-value #13

wolfgang-demeter opened this issue Jan 9, 2022 · 1 comment

Comments

@wolfgang-demeter
Copy link

wolfgang-demeter commented Jan 9, 2022

Regarding the short discussion in https://discuss.flarum.org/d/29812-add-new-validator-to-core/6 i'd like to propose the increase of the max-value for the Posts content validator src/Post/PostValidator.php.

The MySQL-database field type for posts.content was changed from text to mediumtext, which can contain up to 16777215 bytes of data, instead of the 65535 bytes for text.

As @clarkwinkelmann pointed out, the parsed XML of the TextFormatter XML format can be much bigger, then the content entered in the input field. That should be taken into account when increasing the value. But btw. that wasn't considered previously, when text matched the validator with 65535 bytes!

Germany wouldn't be Germany, without definig a Norm-page wich contains approx. 1800 characters (including spaces). Which means you could roughly post about 36 pages worth of text (without formatting) with the current constraint of 65535 charachters.
While this is fine for the majority of posts, there are certain use-cases one could think of, which require more text. Like for example detailed analysis, essays or reviews or some scientific work or some extensively formatted content.

I don't have an exact max-value in mind, but if you take a quarter of 16777215 you come up with 4194304, which imho leaves enough room for anything TextFormatter could add.

This should not have any impact on the MySQL search performance. On the contrary. Wildcard-searching in one post should be more efficent then searching over multiple posts in the database - considering the same content (length) being searched.

If not increasing it in general, another option could be to have a select box with pre-defined values or a input-number field in the base settings of Flarum to determine the max value for each installation.

@clarkwinkelmann
Copy link
Member

clarkwinkelmann commented Jan 12, 2022

Addendum: the validation rule is actually on the TextFormatter XML because both PostReplyHandler and EditPostHandler feed the validator with $post->getAttributes(), which skips the getContentAttribute() accessor.

So we could put the actual database max column size in there.

But maybe we should also have a validation rule for the non-XML max post size? It could be confusing if we throw a validation error to the user with the length of the XML, and when they compare it with their text length in the editor it doesn't match.

Maybe the "fallback" database validation should have a custom error message like "The internal representation of the post is too big for the database. Try shortening the post", but ideally it would never show up if we set a shorter validation for the actual input.

@askvortsov1 askvortsov1 transferred this issue from flarum/framework Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants