Core: Custom style limit issue

Created on 30 Jul 2018  ·  8Comments  ·  Source: flarum/core

Bug Report

Current Behavior
The custom CSS/LESS area has a limit after 2775 lines (maybe less, it trimmed more) and deletes the rest of the style.

Steps to Reproduce

  1. Go to the administration panel
  2. Click on appearance
  3. Click on the custom style button
  4. Insert a long CSS code
  5. Submit
  6. See error (you may see Flarum not loading the CSS code because of bracket issue)

Expected Behavior
The CSS/LESS area should accept every style file, even infinite ones (extensions do).

Environment

  • Flarum version: 0.1.0-beta.7
  • Website URL: localhost
  • Webserver: apache
  • Hosting environment: localhost
  • Browser: Firefox Quantum
typbug

All 8 comments

My preferred solution: Enforce the limit as a validation rule and show an error message when trying to save content that is too long.

IMO, the limit itself is fine. This input field is not meant to contain an entire theme's worth of CSS. After all, too much CSS can be bad for performance as well. You probably don't want "infinite" CSS. :wink:

By the way, in beta8, with this issue fixed, at least the forum should not stop working anymore.

In agreement with Franz on this one. The custom style option is meant of smaller/minor changes. Not for the compiled Material Design. Adding a validator makes most sense. Complex solutions should be implemented as extensions.

Yes, we should have a validator. And yes, we should discourage putting a lot of CSS in the custom CSS box.

But, we shouldn't disallow it, especially unintentionally. The truncation is a symptom of the settings.value column being TEXT datatype. We cannot exclude extensions needing to store settings values longer than 64kb. And we cannot exclude valid use-cases where someone wants to put >64kb of CSS in the box. I propose that we change the column datatype to MEDIUMTEXT.

And we cannot exclude valid use-cases where someone wants to put >64kb of CSS in the box.

Could you offer such a use-case? Especially after you also wrote this:

And yes, we should discourage putting a lot of CSS in the custom CSS box.

:wink:

I don't think 64kb of CSS is that much when you consider whitespace, comments, LESS mixins. Yes if you had this much the better solution would be making it into an extension but this is not always possible (e.g. where you want to allow a client to easily customise their CSS). We can discourage large amounts, but 64kb is too small for a hard limit.

Medium or Longtext would be okay, as long as there's a strict validation occurring..

Medium please: 👍
```txt
TEXT | 65,535 (216−1) bytes = 64 KiB
MEDIUMTEXT | 16,777,215 (224−1) bytes = 16 MiB
LONGTEXT | 4,294,967,295 (232−1) bytes = 4 GiB

Was this page helpful?
0 / 5 - 0 ratings

Related issues

datitisev picture datitisev  ·  4Comments

webpigeon picture webpigeon  ·  3Comments

Ralkage picture Ralkage  ·  4Comments

tjrgg picture tjrgg  ·  3Comments

MichaelBelgium picture MichaelBelgium  ·  4Comments