Skip to content

fix: decode XML escapes and CDATA in sitemap <loc> values - #168

Closed
saviourmk wants to merge 1 commit into
agent-ecosystem:mainfrom
saviourmk:fix/sitemap-loc-entities
Closed

saviourmk wants to merge 1 commit into
agent-ecosystem:mainfrom
saviourmk:fix/sitemap-loc-entities

Conversation

@saviourmk

Copy link
Copy Markdown

parseSitemapUrls takes the text between <loc> and </loc> as the URL without decoding it. The sitemap protocol requires & in a URL to be written as &amp;, so a sitemap index entry like https://example.com/sitemap.xml?page=2&amp;type=docs is fetched with a literal &amp; in the query and that child sitemap is never read. Page URLs with query strings get the same treatment. A <loc> wrapped in CDATA, which some generators emit, comes out as <![CDATA[...]]>, fails to parse as a URL and is dropped, so a sitemap written that way yields no pages at all.

I added a small locText helper that unwraps a CDATA section and otherwise runs the value through the existing decodeCharacterReferences from classify-markdown-links, and used it for both regular and index sitemaps. URLs without escapes come back unchanged.

The new parseSitemapUrls tests cover &amp;, &apos; and a numeric reference in a regular sitemap, &amp; in a sitemap index, and a CDATA-wrapped <loc>. All three fail on main.

Fixes #167

@dacharyc

Copy link
Copy Markdown
Member

Thanks for the report. I've confirmed the bug described in the linked issue, and I’ll keep the issue open to track it.

I'm closing this PR, though. This project doesn't accept unsolicited, agent-generated pull requests from accounts with no prior involvement in the project. This PR arrived as part of a batch of six across two repositories in about 40 minutes, each opened seconds after its issue, and as an indie dev with limited resources, I can't take on reviewing and maintaining code submitted that way.

I'll triage and handle the bug fixes on a schedule that is consistent with my resources and the bug’s impact.

If you use this tool and run into problems with it, issues describing what you were doing and what went wrong are welcome.

@dacharyc dacharyc closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sitemap <loc> values are used without decoding XML escapes

2 participants