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

Modules break if content entered exceeds 65535 characters #24631

Closed
ricomonkeon opened this issue Apr 17, 2019 · 9 comments
Closed

Modules break if content entered exceeds 65535 characters #24631

ricomonkeon opened this issue Apr 17, 2019 · 9 comments

Comments

@ricomonkeon
Copy link

Steps to reproduce the issue

Create a module containing a field type of editor.
Using this module, enter any content which exceeds 65535 characters.

Expected result

An admin would expect it just to save all the content, but realistically a warning saying you cannot enter that much content, and the ability to edit down accordingly would seem sensible.

Actual result

An "Error decoding JSON data" error appears on both the front and back end of the site (when you try and edit the module, or view it on the front). The module cannot then be accessed via the admin, and if you go into the database you notice that the JSON string is incomplete, as it has only saved the first 65535 characters.

Additional comments

I suspect what is required is to validate the json string for length before adding it to the database.

I tried using the customContent method of adding data. This doesn't break as seriously (as it does not use json), but any additional characters are also cropped.

@brianteeman
Copy link
Contributor

Why on earth are you putting war and peace in a module?

@ricomonkeon
Copy link
Author

Heheh. It was actually an admin copy-pasting an image which triggered it - the editor converts that to base64 (which uses a lot of characters).


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24631.

@joeforjoomla
Copy link
Contributor

joeforjoomla commented Apr 17, 2019

This happened to one extension of mine too.
Saving editor contents in a single JSON database field it's not so difficult that users exceed that 65535 bytes limit.
I had to include a check into my extension to prevent saving and warn the user in this situation, indeed being this field used by a system plugin, the result was a disaster. The entire website frontend/backend was likely to be unreachable showing "Error decoding JSON data" error

@brianteeman
Copy link
Contributor

If you submitted a PR then everyone would benefit

@ghost ghost added the J3 Issue label Apr 18, 2019
@mbabker
Copy link
Contributor

mbabker commented Apr 18, 2019

This is a repeat of the usual "X field in Y table should be changed from TEXT to LONGTEXT because I'm trying to store too much data into this database column" request, only I think this might be the first for #__modules.content (usually it's the #__extensions or #__template_styles tables, though I also vaguely remember one issue in the past because people someone was trying to do full articles in modules instead of using com_content).

@Quy
Copy link
Contributor

Quy commented Apr 18, 2019

I also vaguely remember one issue in the past because people someone was trying to do full articles in modules instead of using com_content

Maybe this one #19618

@ricomonkeon
Copy link
Author

I don't think it should be changed to LONGTEXT - it's ultimately a mistake to add that much text. The bug I'm reporting is that it breaks the site rather than fails gracefully, due to the field containing a JSON string which is not being validated for its length and so becomes invalid when it doesn't save properly.

Admins always do unexpected things they they need to be told not to - massive images etc, but to be able to actually break the site doing something unwise but understandable (pasting an image into the editor in this case) seems like a bug that needs fixing.

It could perhaps be argued that the issue is TinyMCE converting pasted images to base64, I suppose. The result is the same.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24631.

@alikon
Copy link
Contributor

alikon commented Apr 18, 2019

with #24635 now a check is made to prevent this behaviour
please test

@ghost
Copy link

ghost commented Apr 18, 2019

Closed as having Pull Request.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants