gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

CONCATENATE_SCRIPTS is ignored by Gutenberg

Open MatzeKitt opened this issue 8 years ago • 7 comments

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

  1. Disable CONCATENATE_SCRIPTS.
  2. Disable access to /wp-admin/load-scripts.php in the server settings.
  3. Add a new post.
  4. Add a new block.
  5. 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.

MatzeKitt avatar Mar 19 '18 20:03 MatzeKitt

This appears somewhat related to issues #5381 and #5374 (the last one being open).

zakoops avatar Mar 19 '18 21:03 zakoops

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

mcsf avatar Apr 09 '18 13:04 mcsf

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.

noisysocks avatar Apr 10 '18 02:04 noisysocks

Related #4150

danielbachhuber avatar May 29 '18 17:05 danielbachhuber

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.

chrisvanpatten avatar Oct 18 '18 20:10 chrisvanpatten

Is this still an issue now that Code Mirror is not loaded at all?

youknowriad avatar Oct 29 '18 13:10 youknowriad

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.

danielbachhuber avatar Oct 29 '18 13:10 danielbachhuber