only prefix namespace names onto titles that lack them

WikiqPage unconditionally prepended the namespace name to titles of
pages outside the main namespace. mwxml >= 0.3.7 keeps the namespace
prefix on the title when the dump carries <ns> tags (it previously
stripped it), which made wikiq emit double-prefixed titles like
"Category:Category:Alaska". Check for the prefix before adding it.
mwxml still strips the prefix on its fallback path for dumps without
<ns> tags, so those titles are still prefixed as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 16:05:44 -07:00
parent 3ab988d6eb
commit ec09641545

View File

@@ -385,8 +385,12 @@ class WikiqPage:
# page.namespace is inconsistent with namespace_map # page.namespace is inconsistent with namespace_map
if page.namespace not in namespace_map: if page.namespace not in namespace_map:
page.namespace = 0 page.namespace = 0
# mwxml >= 0.3.7 keeps the namespace prefix on the title when the dump
# has <ns> tags, but strips it on the no-<ns> fallback path
if page.namespace != 0: if page.namespace != 0:
page.title = ":".join([namespace_map[page.namespace], page.title]) ns_prefix = namespace_map[page.namespace] + ":"
if not page.title.startswith(ns_prefix):
page.title = ns_prefix + page.title
self.restrictions = page.restrictions self.restrictions = page.restrictions
self.collapse_user = collapse_user self.collapse_user = collapse_user
self.mwpage = page self.mwpage = page