Xqt submitted this change.
[bugfix] Allow categories when saving IndexPage
It is possible to have categories in IndexPage.
Take them into consideration when validating page content,
otherwise it will not be possible to save the page.
Bug: T299806
Change-Id: I58c0370a938958d7f2800b7b099992526db0d0df
---
M pywikibot/proofreadpage.py
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 7096f32..8fca578 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -860,13 +860,21 @@
def has_valid_content(self) -> bool:
"""Test page only contains a single call to the index template."""
- if (not self.text.startswith('{{' + self.INDEX_TEMPLATE)
- or not self.text.endswith('}}')):
+ text = self.text
+
+ if not text.startswith('{{' + self.INDEX_TEMPLATE):
+ return False
+
+ # Discard possible categories after INDEX_TEMPLATE
+ categories = textlib.getCategoryLinks(text, self.site)
+ for cat in categories:
+ text = text.replace('\n' + cat.title(as_link=True), '')
+
+ if not text.endswith('}}'):
return False
# Discard all inner templates as only top-level ones matter
- templates = textlib.extract_templates_and_params_regex_simple(
- self.text)
+ templates = textlib.extract_templates_and_params_regex_simple(text)
if len(templates) != 1 or templates[0][0] != self.INDEX_TEMPLATE:
# Only a single call to the INDEX_TEMPLATE is allowed
return False
To view, visit change 756061. To unsubscribe, or for help writing mail filters, visit settings.