Repository navigation
fix(crawler): read a sitemap whose root is prefixed with the sitemap namespace #759 - #792
Merged
Merged
Conversation
nc9
force-pushed
the
fix/prefixed-sitemap-root-759
branch
from
October 15, 2026 01:50
c2bdcfb to
33a1ae0
Compare
4 tasks
nc9
marked this pull request as ready for review
October 15, 2026 03:51
|
Reviewed the diff. I didn't run the tests; I read the code and the new test file. The fix looks correct and well scoped. It only strips prefixes when the root's own
I found no blocking issues. |
…namespace #759 A urlset or sitemapindex written as <ns0:urlset xmlns:ns0="...sitemap/0.9">, as Python's ElementTree writes one, read as "Unknown sitemap format" and lost every URL. When the root's prefix is bound to a sitemap namespace, strip that prefix from the element names before reading; a prefix bound to any other namespace stays an unknown format. Signed-off-by: Nik Cubrilovic <[email protected]>
… second root #759 Review follow-up. fast-xml-parser refuses <__proto__> but not <ns0:__proto__>, so stripping the prefix assigned __proto__ on the copy: refuse it the same way. An element written both prefixed and not now stays a repeat (flagged as one) instead of the last one winning. An unprefixed root is read as before when a prefixed one sits beside it, and a root prefixed news: bound to the sitemap namespace is not a news sitemap. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/prefixed-sitemap-root-759
branch
from
October 15, 2026 03:53
33a1ae0 to
75ac5e1
Compare
|
Reviewed the diff for I found no blocking problems. The fix is narrow and well scoped, and the tests cover the edge cases.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #759.
What was wrong
parseSitemaplooked for a root element named exactlyurlsetorsitemapindex. A sitemap that binds the sitemap namespace to a prefix, such as<ns0:urlset xmlns:ns0="http://www.sitemaps.org/schemas/sitemap/0.9"><ns0:url><ns0:loc>…, was reported bycrawl/sitemap-validasUnknown sitemap format, and none of its URLs were read. Python's ElementTree writes this form by default when a namespace is registered without an empty prefix, and it is valid XML in the sitemap namespace. The body sniffing indecodeSitemapBodyalready accepted the prefixed root, so the file was treated as a sitemap and then failed to parse as one.The fix
When the parsed root is
<prefix>:urlsetor<prefix>:sitemapindex, and that element bindsxmlns:<prefix>to a sitemap namespace, the prefix is taken off every element name in the tree before the existing reader runs.news:, are left alone. Soxmlns:newsstill marks a news sitemap.Unknown sitemap format.The unprefixed form is unchanged.
Tests
packages/crawler/tests/sitemap-prefixed-root-759.test.ts:Unknown sitemap format;decodeSitemapBody) reads a prefixed sitemap.Four of the five fail on main. Also passing: sitemap-xml-escapes, sitemap-field-text-687, sitemap-news-namespace, sitemap-gzip, sitemap-entity-expansion, sitemap-guessed-html, sitemap-gate, and rules sitemap-valid. tsgo passes in crawler,
tangly check --strictpasses, and detect-secrets is clean.Docs and skill
rules/crawl/sitemap-validnow says when a prefixed root counts. There's a CHANGELOG entry under Fixed. The squirrelscan agent skill needs no change.