FriendsOfShopware / FroshDevelopmentHelper

Helpful development tools
81 stars 15 forks source link

HTML comments in sitemap.xml are making it invalid #46

Closed kaiserkiwi closed 2 years ago

kaiserkiwi commented 2 years ago

PHP Version

8.0.20

Shopware Version

v6.4.9.0

Actual behaviour

In the generated XML-File for the are HTML comments before the xml declaration. That causes the sitemap.xml to be invalid.

Code with the plugin activated

<!-- INCLUDE BEGIN @Storefront/storefront/page/sitemap/sitemap.xml.twig (vendor/shopware/storefront/Resources/views/storefront/page/sitemap/sitemap.xml.twig) --><!-- BLOCK BEGIN sitemap (vendor/shopware/storefront/Resources/views/storefront/page/sitemap/sitemap.xml.twig) --><?xml version="1.0" encoding="UTF-8"?>
<!-- BLOCK BEGIN sitemap_content (vendor/shopware/storefront/Resources/views/storefront/page/sitemap/sitemap.xml.twig) -->    <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <!-- BLOCK BEGIN sitemap_content_sitemaps (vendor/shopware/storefront/Resources/views/storefront/page/sitemap/sitemap.xml.twig) -->                            <sitemap>
                    <loc>[*redacted SITEMAP-URL]</loc>
                    <lastmod>2022-06-16T12:42:00+02:00</lastmod>
                </sitemap>
                    <!-- BLOCK END sitemap_content_sitemaps -->    </sitemapindex>
<!-- BLOCK END sitemap_content --><!-- BLOCK END sitemap --><!-- INCLUDE END @Storefront/storefront/page/sitemap/sitemap.xml.twig -->

Code without the plugin activated

<?xml version="1.0" encoding="UTF-8"?>
    <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
                                    <sitemap>
                    <loc>[*redacted SITEMAP-URL]</loc>
                    <lastmod>2022-06-16T13:15:51+02:00</lastmod>
                </sitemap>
                        </sitemapindex>

Most of these comments are no problem but the comments before <?xml version="1.0" encoding="UTF-8"?> are invalidating the file.

Expected behaviour

There shouldn't be any characters before <?xml version="1.0" encoding="UTF-8"?> as the XML specification doesn't allow this.

Steps to Reproduce?

  1. Activate Plugin
  2. Access the sitemap.xml for the current shop