jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312258?usp=email )
Change subject: [cleanup] Fix incomplete URL substring sanitization (CodeQL)
......................................................................
[cleanup] Fix incomplete URL substring sanitization (CodeQL)
Two places in the codebase were checking "is this URL trusted?" by
looking for a known domain name anywhere inside the URL string, e.g.
'jstor.org' in link. That check can be fooled - a URL like
https://jstor.org.attacker.com/phish contains the text "jstor.org"
too, even though it isn't a JSTOR link at all.
Replaced both checks with proper URL parsing, so we now compare
against the actual hostname instead of just searching for a
substring:
* pywikibot/data/sparql.py: the code that detects a Wikimedia Commons
login redirect now checks the parsed hostname instead of searching
for "commons-query.wikimedia.org" anywhere in the URL.
* scripts/reflinks.py: the JSTOR link skip-check now checks the
parsed hostname (and its subdomains) instead of searching for
"jstor.org" anywhere in the link.
Bug: T432508
Change-Id: I0950512ec5bd00711ab17c8047ab36a0842fc4f2
---
M pywikibot/data/sparql.py
M scripts/reflinks.py
2 files changed, 5 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/sparql.py b/pywikibot/data/sparql.py
index d259326..1d43f3a 100644
--- a/pywikibot/data/sparql.py
+++ b/pywikibot/data/sparql.py
@@ -8,7 +8,7 @@
from textwrap import fill
from typing import Any, cast
-from urllib.parse import quote
+from urllib.parse import quote, urlparse
from requests import JSONDecodeError, Response
from requests.exceptions import Timeout
@@ -170,7 +170,7 @@
# not in case the response otherwise might have it in between
strcontent = self.last_response.content.decode()
if (strcontent.startswith('<!DOCTYPE html>')
- and 'https://commons-query.wikimedia.org' in url
+ and urlparse(url).hostname == 'commons-query.wikimedia.org'
and ('Special:UserLogin' in strcontent
or 'Special:OAuth' in strcontent)):
raise NoUsernameError(fill(
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 99f9344..2dac3ad 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -63,6 +63,7 @@
from http import HTTPStatus
from pathlib import Path
from textwrap import shorten
+from urllib.parse import urlparse
import pywikibot
from pywikibot import comms, config, i18n, pagegenerators, textlib
@@ -562,7 +563,8 @@
# for each link to change
for match in linksInRef.finditer(raw_text):
link = match['url']
- if 'jstor.org' in link:
+ hostname = urlparse(link).hostname or ''
+ if hostname == 'jstor.org' or hostname.endswith('.jstor.org'):
# TODO: Clean URL blacklist
continue
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312258?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0950512ec5bd00711ab17c8047ab36a0842fc4f2
Gerrit-Change-Number: 1312258
Gerrit-PatchSet: 1
Gerrit-Owner: Nihar_Chakravarti <niharchakravarti05(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1202123?usp=email )
Change subject: fix pywikibot.site.logenvents() start, end and reverse documentation
......................................................................
fix pywikibot.site.logenvents() start, end and reverse documentation
Bug: T407052
Change-Id: I1aeb13bb794b29c7574b995bba5b922bb126ef0a
---
M pywikibot/site/_generators.py
1 file changed, 6 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 4639bf6..c4b4851 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1403,13 +1403,12 @@
namespaces will be fetched from the API and will be
filtered later during iteration.
- :param start: Only iterate entries from and after this Timestamp
- :param end: Only iterate entries up to and through this
- Timestamp
- :param reverse: If True, iterate oldest entries first (default:
- newest)
- :param tag: Only iterate entries tagged with this tag
- :param total: Maximum number of events to iterate
+ :param start: The timestamp to start enumerating from.
+ :param end: The timestamp to end enumerating at.
+ :param reverse: If ``True``, enumerate the oldest entries first.
+ In this case, *start* must be earlier than *end*.
+ :param tag: only iterate entries tagged with this tag
+ :param total: maximum number of events to iterate
:raises KeyError: The namespace identifier was not resolved
:raises TypeError: The namespace identifier has an inappropriate
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1202123?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1aeb13bb794b29c7574b995bba5b922bb126ef0a
Gerrit-Change-Number: 1202123
Gerrit-PatchSet: 13
Gerrit-Owner: Ezra yendau <ezrayendau2000(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zache-tool <kimmo.virtanen(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312242?usp=email )
Change subject: tests: remove test_proofreadwiki and en.citizendium.org test
......................................................................
tests: remove test_proofreadwiki and en.citizendium.org test
Both test fails due to ClientError 403 - authorization will not help.
A Cloudflare Bot Challenge blocks API access.
Bug: T404583
Bug: T331223
Change-Id: Ic32b59f76a4c50c23d414e0744164d1b8a354586
---
M tests/site_detect_tests.py
1 file changed, 0 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py
index e6dadbb..c6094e3 100755
--- a/tests/site_detect_tests.py
+++ b/tests/site_detect_tests.py
@@ -7,7 +7,6 @@
"""Test for site detection."""
from __future__ import annotations
-import os
import unittest
from contextlib import suppress
from http import HTTPStatus
@@ -60,7 +59,6 @@
standard_version_sites = (
'http://www.ck-wissen.de/ckwiki/index.php?title=$1',
- 'http://en.citizendium.org/wiki/$1',
'http://www.wikichristian.org/index.php?title=$1',
)
@@ -104,17 +102,8 @@
for url in self.standard_version_sites:
nl = urlparse(url).netloc
with self.subTest(url=nl):
- if os.getenv('GITHUB_ACTIONS') and nl == 'en.citizendium.org':
- self.skipTest('Skip test on github due to T404583')
-
self.assertSite(url)
- def test_proofreadwiki(self) -> None:
- """Test detection of proofwiki.org site."""
- if os.getenv('GITHUB_ACTIONS'):
- self.skipTest('Skip test on github due to T331223')
- self.assertSite('http://proofwiki.org/wiki/$1') # pragma: no cover
-
def test_non_standard_version_sites(self) -> None:
"""Test detection of non standard MediaWiki sites."""
for url in self.non_standard_version_sites:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312242?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic32b59f76a4c50c23d414e0744164d1b8a354586
Gerrit-Change-Number: 1312242
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312210?usp=email )
Change subject: doc: Fix several spelling mistakes
......................................................................
doc: Fix several spelling mistakes
Change-Id: I6f4059f724a4d880d94b520dfd912ed3199c2c69
---
M HISTORY.rst
M README.rst
M pywikibot/config.py
M pywikibot/exceptions.py
M pywikibot/page/_basepage.py
M pywikibot/site/_apisite.py
M pywikibot/textlib.py
M pywikibot/tools/__init__.py
M setup.py
9 files changed, 18 insertions(+), 16 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/HISTORY.rst b/HISTORY.rst
index 49009cf..8e4f55d 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -5,7 +5,7 @@
------
*11 July 2026*
-* Dreprecate ``cross_projects`` :mod:`family.Family` settings (:phab:`T431178`)
+* Deprecate ``cross_projects`` :mod:`family.Family` settings (:phab:`T431178`)
* Deprecate :func:`family.Family.post_get_convert` and
:func:`family.Family.pre_put_convert` functions (:phab:`T431188`)
* Update :mod:`families.wikiquote_family`
diff --git a/README.rst b/README.rst
index 41d24b9..cbaebc4 100644
--- a/README.rst
+++ b/README.rst
@@ -128,7 +128,7 @@
options[opt[1:]] = value
MyBot(generator=gen_factory.getCombinedGenerator(), **options).run()
- if __name == '__main__':
+ if __name__ == '__main__':
main()
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 405a183..4830dd2 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -154,7 +154,7 @@
# True for enabling fake UA, False for disabling / using pywikibot's own UA,
# str to specify custom UA.
fake_user_agent_default = {'reflinks': False, 'weblinkchecker': False}
-# Website domains excepted to the default behaviour.
+# Website domains that are exceptions to the default behaviour.
# True for enabling, False for disabling, str to hardcode a UA.
# Example: {'problematic.site.example': True,
# 'prefers.specific.ua.example': 'snakeoil/4.2'}
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 7aa1831..3ff630c 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -77,7 +77,6 @@
Error: Base class, all exceptions should the subclass of this class.
- CaptchaError: Captcha is asked and config.solve_captcha == False
- - ClientError: A problem with the client request
- AutoblockUserError: requested action on a virtual autoblock user not valid
- InvalidTitleError: Invalid page title
- NoUsernameError: Username is not in user config file, or it is invalid.
@@ -134,9 +133,12 @@
ServerError: a problem with the server.
- FatalServerError: A fatal/non-recoverable server error
- - Server414Error: Server timed out with HTTP 414 code
- Server504Error: Server timed out with HTTP 504 code
+ClientError: A problem with the client request
+
+ - Client414Error: HTTP 414 code - URI too long
+
WikiBaseError: any issue specific to Wikibase.
- NoWikibaseEntityError: entity doesn't exist
diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index 5062f00..7dcfc50 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -1437,7 +1437,7 @@
"""Save the page with the contents of the first argument as the text.
This method is maintained primarily for backwards-compatibility.
- For new code, using :meth:`save` is preferred; also ee that
+ For new code, using :meth:`save` is preferred; also see that
method docs for all parameters not listed here.
.. version-added:: 7.0
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 772da46..6965b9c 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -1113,14 +1113,14 @@
) -> str:
"""Parse the given text for preprocessing and rendering.
- e.g expand templates and strip comments if includecomments
- parameter is not True. Keeps text inside <nowiki></nowiki> tags
- unchanges etc. Can be used to parse magic parser words like
+ Expand templates and strip comments if *includecomments*
+ parameter is not ``True``. Keeps text inside ``<nowiki></nowiki>``
+ tags unchanged. Can be used to parse magic parser words like
{{CURRENTTIMESTAMP}}.
:param text: Text to be expanded
:param title: Page title without section
- :param includecomments: If True do not strip comments
+ :param includecomments: If ``True`` do not strip comments
"""
if not isinstance(text, str):
raise ValueError('text must be a string')
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index a5d594f..b4fd34f 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -577,7 +577,7 @@
and markup. Defaults to :code:`['tt', 'nowiki', 'small', 'sup']`
if None.
:param removetags: List of tag names whose tags and content should
- be removed. The tags ca be preserved if listed in *keeptags*.
+ be removed. The tags can be preserved if listed in *keeptags*.
Defaults to :code:`['style', 'script']` if None.
:return: The cleaned text with specified HTML parts removed.
"""
@@ -1799,7 +1799,7 @@
:param oldtext: Content of the old category
:param oldcat: :class:`pywikibot.Category` object of the old
category
- :param newcat: :class:`Pywikibot.Category` object of the new
+ :param newcat: :class:`pywikibot.Category` object of the new
category
:param add_only: If add_only is True, the old category won't be
replaced and the category given will be added after it.
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 940cf96..dda6e78 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -884,9 +884,9 @@
Result is expressed as hexdigest().
.. version-added:: 3.0
- .. version-changed:: 8.2
- The *sha* parameter may also be a hash constructor, or a callable
- that returns a hash object.
+ .. version-changed:: 8.2
+ The *sha* parameter may also be a hash constructor, or a callable
+ that returns a hash object.
:param filename: Filename path
diff --git a/setup.py b/setup.py
index 419974c..66ffcbe 100755
--- a/setup.py
+++ b/setup.py
@@ -15,7 +15,7 @@
make_dist -remote
- create a new tag with the version number of the final release
-- synchronize the local tags with the remote repositoy
+- synchronize the local tags with the remote repository
- merge current master branch to stable branch
- push new stable branch to Gerrit and merge it the stable repository
- prepare the next master release by increasing the version number in
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312210?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6f4059f724a4d880d94b520dfd912ed3199c2c69
Gerrit-Change-Number: 1312210
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot