-
Notifications
You must be signed in to change notification settings - Fork 9.4k
CSS file is deferred when CSS element has defer attribute in default_head_blocks.xml. #37814
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
Open
nurullah
wants to merge
13
commits into
magento:2.4-develop
Choose a base branch
from
nurullah:2.4-develop
base: 2.4-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
597fd24
Added non-critical CSS attributes when defer parameter pass on css el…
nurullah 7b65739
Deferred css file added in noscript tag to work when javascript is di…
nurullah c9a52f3
type=preload mistake fixed.
nurullah 35a7260
Updated RendererTest inputs.
nurullah ad4e4cf
Fixed double space problem between tagname and attributes.
nurullah 86ed4e6
Unit test added for defer attribute.
nurullah 6a868e1
Unused local variable removed.
nurullah 36917b9
Removed unnecessary defer attribute from CSS output.
nurullah f8d0db8
Fixed: PHPCS Inline control structures.
nurullah 33fa192
escapeHtmlAttr function is used in the head element values for securi…
nurullah 90c50ef
escapeHtmlAttr is used in getGroupAttributes value.
nurullah 8f4ff6a
Merge branch '2.4-develop' into 2.4-develop
nurullah 3cb0c63
Merge branch '2.4-develop' into 2.4-develop
nurullah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
escapeHtmlAttr
instead ofescapeHtml
I think?And in the case of the
onload
one, it should beescapeJs
inside aescapeHtmlAttr
according to the docs:Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
escapeHtmlAttr
function escapes slash character and it looks like the below;It's pretty useful for body element attributes but not for head element attributes. Also, before this pull request, the same
escapeHtml
function was used for the attribute value.magento2/lib/internal/Magento/Framework/View/Page/Config/Renderer.php
Lines 332 to 334 in 0a834cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I know too little about this, would be great if somebody with a little bit of security knowledge could double check this here then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nathanjosiah: if you have a little bit of time, do you have some input here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the main issue is that escapeHtmlAttr escaped all chars then that is correct behavior even for head.
For example:
The text would be green.
Here is a small demo that shows this off.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
escapeHtmlAttr
is appropriate for all attributes including script attributes. You would only need to combineescapeJs
withescapeHtmlAttr
if there is additional content being injected into the JS. For example from our devdocsAs far as I can see, this PR is using the escaper methods correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this PR is still waiting for your review @hostep. If there are no other problems, can you take this to the next step? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a lot of expert knowledge on the subject but since somebody forced me to review this (I wasn't able to unassign myself), I approved it anyways.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be advised that because of too much escaping we end up with this in page source:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sky-hub: and how is that a problem? A browser should be able to decode those without an issue. It's like writing
>
or<
in the html source to display>
or<
. In this case/
translates to/
for example. It's redundant and will increase the payload size a bit sure, but it shouldn't break anything.