Skip to content

Commit

Permalink
Use createElementNS for namespaced XML elements (see #6157)
Browse files Browse the repository at this point in the history
Description
-----------

~~WIP~~

See #6154

Using `createElement()` for namespaced elements is wrong, see https://dom.spec.whatwg.org/#ref-for-dom-document-createelement%E2%91%A0

Commits
-------

1951826 WIP
c13c331 WIP
b5c1220 WIP
323eec0 WIP
104ebc6 WIP
1b43c8b WIP
ea7434a WIP
5bce909 WIP
0a10c0c Fix namespaced elements
5521c56 Revert
27f5238 WIP
9e8604b WIP
109bf12 Fix
  • Loading branch information
ausi committed Aug 8, 2023
1 parent 22e356c commit 648d6e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core-bundle/src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public function __invoke(Request $request): Response
$urlSet = $sitemap->createElementNS('https://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');

foreach ($urls as $url) {
$loc = $sitemap->createElement('loc');
$loc = $sitemap->createElementNS($urlSet->namespaceURI, 'loc');
$loc->appendChild($sitemap->createTextNode($url));

$urlEl = $sitemap->createElement('url');
$urlEl = $sitemap->createElementNS($urlSet->namespaceURI, 'url');
$urlEl->appendChild($loc);
$urlSet->appendChild($urlEl);
}
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/src/Event/SitemapEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public function addUrlToDefaultUrlSet(string $url): self
return $this;
}

$loc = $sitemap->createElement('loc');
$loc = $sitemap->createElementNS($urlSet->namespaceURI, 'loc');
$loc->appendChild($sitemap->createTextNode($url));

$urlEl = $sitemap->createElement('url');
$urlEl = $sitemap->createElementNS($urlSet->namespaceURI, 'url');
$urlEl->appendChild($loc);
$urlSet->appendChild($urlEl);

Expand Down

0 comments on commit 648d6e3

Please sign in to comment.