magento2: Problem with adding google fonts with ampersand into default_head_blocks.xml
If I insert info
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
this code
<link src="//fonts.googleapis.com/css?family=Open+Sans|Roboto+Condensed|Open+Sans+Condensed:400,300,300italic,400italic,600,600italic,700italic,700&subset=latin,cyrillic" src_type="url" />
I got errors Theme layout update file default_head_blocks.xml' is not valid. EntityRef: expecting ';'
and if I replace & with &
I got exception.
or If I remove &subset=latin,cyrillic
- works perfectly
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 47 (27 by maintainers)
Commits related to this issue
- Merge pull request #2228 from magento-tsg/2.2.4-develop-pr21 [TSG] Backporting for 2.2 (pr21) (2.2.4) — committed to magento/magento2 by deleted user 6 years ago
- github-issue; #2228; Fixes to Simplexml Element class to satisfy static tests — committed to sergey-solo/magento2 by sergey-solo 5 years ago
- github-issue; #2228; Fixes to Simplexml Element class to satisfy static tests — committed to sergey-solo/magento2 by sergey-solo 5 years ago
- github-issue; #2228; Fixes to Simplexml Element class to satisfy static tests — committed to sergey-solo/magento2 by sergey-solo 5 years ago
- github-issue; #2228; Encode xml entities in tag attributes — committed to magento/magento2 by sergey-solo 5 years ago
- ENGCOM-5761: #2228; Encode xml entities in tag attributes #24336 - Merge Pull Request magento/magento2#24336 from sergey-solo/magento2:m2-github-issue/2228 - Merged commits: 1. de8028e3db97d8570... — committed to magento/magento2 by magento-engcom-team 5 years ago
- ENGCOM-5761: #2228; Encode xml entities in tag attributes #24336 — committed to magento/magento2 by sidolov 5 years ago
Unbelievable. Magento, you cannot reproduce this? I was wondering… how do you manage to reproduce more serious bugs?? You just need to put ONE line of code in your XML and you will reproduce it. there are no 100 steps, there are no 100 files. amazing!
What’s even more amazing - this was reported 3 years ago.
Hey guys. Replacing
&
in the path with&amp;amp;
seems to work for me. The problem seems that the xml code is escaped three times for me. If it does not work for you, try adding or removing theamp;
part as many times as needed until it works.@luckyraul, thank you for your report. We were not able to reproduce this issue by following the steps you provided. If you’d like to update it, please reopen the issue. We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9
@magento-engcom-team good timing (2 year for quick resolve )
@jevgenijmokrousov - As frustrating as software bugs and poor processes can be, there is absolutely zero reason for that harmful statement.
Any update on this issue? it is a major blocker if you are using CDN as you should be for any store that has extended latin alphabet.
Didn’t have time to finish this. Check the line on
lib/internal/Magento/Framework/Simplexml/Element.php:248
Potential fix may be to replace this:
$out .= ' ' . $key . '="' . str_replace('"', '\"', (string)$value) . '"';
with this:
$out .= ' ' . $key . '="' . str_replace('"', '\"', $this->xmlentities($value)) . '"';
Fixes the issue(requires to use
&
instead of just&
) but isn’t fully tested.Can confirm this still exists in 2.2.5
Thanks for investigating further. That may work, but it does not mean it is right! I think you should be able to do
&
. I have a suspicion around decoding and encoding when we merge xml docs. Eg it smells like we are not doing an encode during serialization,