CONCATENATE_SCRIPTS is ignored by Gutenberg
Issue Overview
In order to prevent my server from beeing a victim of the CVE-2018-6389 DoS attack I disabled the automatic concatenation of CONCATENATE_SCRIPTS in my wp-config.php by adding the following line:
define( 'CONCATENATE_SCRIPTS', false );
Then I disabled access to /wp-admin/load-scripts.php completely in my nginx configuration so that trying to access it would result in a 403 – Forbidden.
Now by adding a new custom HTML block I get two 403 errors logged in the console:
[Error] Failed to load resource: the server responded with a status of 403 (HTTP/2.0 403) (load-scripts.php, line 0)
[Error] Failed to load resource: the server responded with a status of 403 (HTTP/2.0 403) (load-styles.php, line 0)
The following requests try to load:
/wp-admin/load-scripts.php?load=wp-codemirror,code-editor,htmlhint,csslint,jshint
/wp-admin/load-styles.php?load=wp-codemirror,code-editor
Steps to Reproduce
- Disable
CONCATENATE_SCRIPTS. - Disable access to
/wp-admin/load-scripts.phpin the server settings. - Add a new post.
- Add a new block.
- Set block to “Custom HTML”.
Used Gutenberg version: 2.4.0 Used WordPress version: 4.9.4 Used browser: Safari 11.0.3
Expected Behavior
The TinyMCE HTML editor should load.
Current Behavior
The TinyMCE HTML editor doesn’t load and ends in an “An unknown error occurred.”.
Possible Solution
Respect setting CONCATENATE_SCRIPTS to false and load the scripts one by one instead of concatenated.
This appears somewhat related to issues #5381 and #5374 (the last one being open).
Alright, I can repro. The culprit would be the Custom HTML block's manual loading of scripts:
https://github.com/WordPress/gutenberg/blob/909d38dca5d48851ca93d0f26e47b851c6039257/components/code-editor/index.js#L14-L44
/cc @noisysocks
Thanks @KittMedia—great catch. We will definitely need to address this before merge. We'll be revisiting how asynchronous components are handled in Gutenberg as part of our work towards an MVP—that would be an ideal time to look into this, I think.
Related #4150
As context based on today's #core bug scrub, there are some lingering references to CodeMirror that may need to be removed, even though CM is no longer used in the HTML block as of cc5bf5c150268b4a48ff9f68a41be5280a894253.
Is this still an issue now that Code Mirror is not loaded at all?
Is this still an issue now that Code Mirror is not loaded at all?
Nope. I've verified that load-scripts.php is no longer in use by Gutenberg.