Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(sitemap): recognize UTF-8 BOM XML before format detection

HelloWorld3326198588666ca3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 648be42..7191653 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- Recognize UTF-8 BOM XML sitemaps during format detection.
+
## [2.5.0] - 2026-10-22
Security and accuracy fixes from a full audit, and Claude Desktop installs again.
diff --git a/scripts/sitemap_discovery.py b/scripts/sitemap_discovery.py
index 9ee766c..c16e3df 100644
--- a/scripts/sitemap_discovery.py
+++ b/scripts/sitemap_discovery.py
@@ -137,7 +137,7 @@ def _sitemap_kind(content: bytes, content_type: str, url: str) -> tuple[str | No
if b"<!DOCTYPE" in content.upper():
return None, "DOCTYPE is not allowed in sitemap XML"
- stripped = content.lstrip()
+ stripped = content.removeprefix(b"\xef\xbb\xbf").lstrip()
if stripped.startswith(b"<"):
try:
parser = etree.XMLParser(
diff --git a/tests/test_sitemap_bom.py b/tests/test_sitemap_bom.py
new file mode 100644
index 0000000..5eff7aa
--- /dev/null
+++ b/tests/test_sitemap_bom.py
@@ -0,0 +1,21 @@
+"""Encoding signatures must not prevent otherwise valid sitemap XML parsing."""
+import sys
+from pathlib import Path
+
+import pytest
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
+from sitemap_discovery import _sitemap_kind # noqa: E402
+
+
[email protected]("root", ["urlset", "sitemapindex", "rss", "feed"])
+def test_utf8_bom_xml_has_the_same_kind(root):
+ xml = f'<?xml version="1.0" encoding="UTF-8"?><{root}/>'.encode()
+ args = ("application/xml", "https://example.com/sitemap.xml")
+ assert _sitemap_kind(xml, *args) == (root, None)
+ assert _sitemap_kind(b"\xef\xbb\xbf" + xml, *args) == (root, None)
+
+
+def test_bom_does_not_bypass_xml_safety_checks():
+ xml = b'\xef\xbb\xbf<!DOCTYPE urlset [<!ENTITY x "unsafe">]><urlset>&x;</urlset>'
+ assert _sitemap_kind(xml, "application/xml", "https://example.com/sitemap.xml")[0] is None