-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Set self closing tags for void elements #33199
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
Set self closing tags for void elements #33199
Conversation
Hi @basvanpoppel. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run WebAPI Tests, Functional Tests EE, Functional Tests CE, Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Can you check fail tests related integrations cases |
@magento run Integration Tests, Unit Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Integration Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Integration tests are fine now. I saw a functional test failing earlier but it seems I can't access it. (also it doesn't seem related to this PR) |
@magento run WebAPI Tests, Static Tests, Semantic Version Checker, Sample Data Tests EE, Sample Data Tests CE, Sample Data Tests B2B, Magento Health Index, Functional Tests EE, Functional Tests CE, Functional Tests B2B, Database Compare |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Thanks you for your contribution |
@magento run Functional Tests CE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
lib/internal/Magento/Framework/View/Helper/SecureHtmlRender/HtmlRenderer.php
Outdated
Show resolved
Hide resolved
The base branch was changed to platform-health to deliver in the scope of the Platform health project. @ihor-sviziev @Den4ik do you think the proposed optimization is important? Did you include |
We don’t need to run array_flip in case if we’ll prepare correct map
…On Tue, 22 Jun 2021 at 22:52, Sergii Ivashchenko ***@***.***> wrote:
The base branch was changed to platform-health to deliver in the scope of
the Platform health project.
@ihor-sviziev <https://github.com/ihor-sviziev> @Den4ik
<https://github.com/Den4ik> do you think the proposed optimization is
important? Did you include array_flip execution time in the benchmark for
isset (or exclude it for in_arrray)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#33199 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOJOUJZ3HMMXZ4TQ4W6I3LTUDSWXANCNFSM46MFKONQ>
.
|
In my opinion it's not super important because array is not so long. But I agree with @ihor-sviziev that we can prepare array with keys and use |
@basvanpoppel would you be able to apply the proposed improvements? |
lib/internal/Magento/Framework/View/Helper/SecureHtmlRender/HtmlRenderer.php
Outdated
Show resolved
Hide resolved
lib/internal/Magento/Framework/View/Helper/SecureHtmlRender/HtmlRenderer.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Ihor Sviziev <ihor-sviziev@users.noreply.github.com>
Co-authored-by: Ihor Sviziev <ihor-sviziev@users.noreply.github.com>
@sivaschenko They have been applied. I've learned something, thanks. :) |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Hi @basvanpoppel, thank you for your contribution! |
Description (*)
This PR adds a fix to prevent html tags to be rendered in a wrong way. If a tag doesn't have content it's always self-closing, adding a script tag without content will therefor not work.
Tags like hr, br, input, img, etc. are forbidden to be closed - they must be self-closing and are not allowed to have content.
This change checks if the element type is void to determine if the tag should be self-closing.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
There's currently no steps you can take inside Magento to test this, as all present script tags have content. Adding a script tag without content (like <script/>, or what happens in many scenarios, <script src="script.js"/>) will trigger the issue.
Questions or comments
I have written a unit test to verify behaviour, please let me know if anything else is needed.
Related to this issue there might be the question wether it's a good practice to add external scripts this way - but this is not the function to validate this - this function should just take care of rendering the html tag.
Contribution checklist (*)