Information Required ? ? Pending

User tests: Successful: Unsuccessful:

avatar zero-24
zero-24
18 Apr 2020

Pull Request for Issue #28557

Summary of Changes

Make sure there renderer does not manipulate the inline CSS and JS

Testing Instructions

Add the following lines to the index.php of the cassiopea template:

// Add inline JavaScript
Factory::getDocument()->addScriptDeclaration('
    window.event("domready", function() {
        alert("An inline JavaScript Declaration");
    });
');

// Add inline Style
Factory::getDocument()->addStyleDeclaration('
	body {
		background: #00ff00;
		color: rgb(0,0,255);
	}
');

Enable CSP (System -> Content-Security-Policy -> Options) and configure like this:
image

  • visit the frontend
  • notice that the styles and scripts are blocked before the patch
  • apply the patch
  • notice it is working now

Expected result

inline script and inline style tags are not modified by the renderer and can be whitelisted via an csp.

Actual result

the style and script renderer add some spaces and line endings that breaks the CSP hash generation.

Documentation Changes Required

none

cc @wilsonge @SharkyKZ

avatar zero-24 zero-24 - open - 18 Apr 2020
avatar zero-24 zero-24 - change - 18 Apr 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 18 Apr 2020
Category Libraries Front End Plugins
avatar zero-24 zero-24 - change - 18 Apr 2020
Labels Added: ? ?
avatar zero-24
zero-24 - comment - 18 Apr 2020

Here is the backport to 3.x: #28720

avatar Bodge-IT
Bodge-IT - comment - 18 Apr 2020

Pls overlook my ignorance, isn't it cassiopea on J4?

avatar zero-24 zero-24 - change - 18 Apr 2020
The description was changed
avatar zero-24 zero-24 - edited - 18 Apr 2020
avatar zero-24
zero-24 - comment - 18 Apr 2020

Yes thanks fixed. I worked in parallel on protostar too :D

avatar richard67 richard67 - change - 18 Apr 2020
Title
[4.0] Make sure there rendere does not manipulate the inline CSS and JS
[4.0] Make sure there renderer does not manipulate the inline CSS and JS
avatar richard67 richard67 - edited - 18 Apr 2020
avatar richard67 richard67 - change - 18 Apr 2020
The description was changed
avatar richard67 richard67 - edited - 18 Apr 2020
avatar richard67 richard67 - change - 18 Apr 2020
Title
[4.0] Make sure there renderer does not manipulate the inline CSS and JS
[4.0] Make sure the renderer does not manipulate the inline CSS and JS
avatar richard67 richard67 - edited - 18 Apr 2020
avatar wilsonge
wilsonge - comment - 18 Apr 2020

This is going to make the source look much worse when debugging. But then again given everyone uses dev tools in browsers these days I guess it doesn't matter much either?

avatar zero-24
zero-24 - comment - 18 Apr 2020

This is going to make the source look much worse when debugging. But then again given everyone uses dev tools in browsers these days I guess it doesn't matter much either?

I have not noticed any difference in the dev tools.

avatar zero-24
zero-24 - comment - 18 Apr 2020

BTW you should not use any inline JS or Inline CSS anyway so one more reason to not use them :D

avatar Bodge-IT
Bodge-IT - comment - 18 Apr 2020

Yes thans fixed. I worked in parallel on protostar too :D

Thanks Tobias, I need a bit more info as running into some wierdness.
With security policy enabled or disabled, I get this warning:
( ! ) Warning: hash() expects parameter 2 to be string, array given in F:\xampp\htdocs\j4test\plugins\system\httpheaders\httpheaders.php on line 178
Can I ignore?
Also, I'm testing this locally, that OK for this PR?

avatar zero-24
zero-24 - comment - 18 Apr 2020

Yes you can ignore it. That is an issue that has been patched here too when you apply the patch that Warning should be gone too.

avatar jwaisner jwaisner - change - 12 Jun 2020
Priority Medium Urgent
avatar zero-24 zero-24 - change - 26 Jun 2020
Labels Added: ?
Removed: ?
avatar vlaucht vlaucht - test_item - 4 Aug 2020 - Tested successfully
avatar vlaucht
vlaucht - comment - 4 Aug 2020

I have tested this item successfully on 169e33e

Tested with Chrome on Win64


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

avatar jmeintrup jmeintrup - test_item - 4 Aug 2020 - Tested successfully
avatar jmeintrup
jmeintrup - comment - 4 Aug 2020

I have tested this item successfully on 169e33e

Tested successfully.


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

avatar richard67
richard67 - comment - 5 Aug 2020

@wilsonge @zero-24 I'm waiting with RTC until your above discussion is resolved.

avatar Fedik
Fedik - comment - 11 Aug 2020

CDATA for xhtml/xml document, and as long as Document may be used for render XML I would keep it. Even if we never used it ?

https://stackoverflow.com/a/66865/1000711

avatar zero-24
zero-24 - comment - 11 Aug 2020

Ok right now to me this PR looks ready than given that I do not touch the CDATA thing and that we only apply hashes on HTML sites anyway.

avatar wilsonge wilsonge - close - 11 Aug 2020
avatar wilsonge wilsonge - merge - 11 Aug 2020
avatar wilsonge wilsonge - change - 11 Aug 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-08-11 18:11:31
Closed_By wilsonge
Labels Added: Information Required ?
Removed: ?
avatar wilsonge
wilsonge - comment - 11 Aug 2020

I'm still not 100% we're getting this right - but let's give it a go

avatar zero-24
zero-24 - comment - 11 Aug 2020

Thanks please merge the backport too: #28720

Add a Comment

Login with GitHub to post a comment