XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/195085

Change subject: [FIX] APISite: Blocked IPv6 usernames in uppercase
......................................................................

[FIX] APISite: Blocked IPv6 usernames in uppercase

The usernames of anonymous users with an IPv6 address are saved with the
letters uppercased. So when querying using such usernames (via bkusers)
those need to be uppercased.

Unfortunately it's possible to fake IPv6 addresses using '::' and those
might have not uppercase letters so it's not uppercasing them.

Change-Id: Iddfb2823cdfae16caa182ba7874beb5a08dd997b
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/85/195085/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 87cd7f1..270849f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -34,6 +34,7 @@
     deprecated, deprecate_arg, deprecated_args, remove_last_args,
     redirect_func, manage_wrapping, MediaWikiVersion, normalize_username,
 )
+from pywikibot.tools.ip import is_IP
 from pywikibot.throttle import Throttle
 from pywikibot.data import api
 from pywikibot.exceptions import (
@@ -3577,6 +3578,12 @@
         if blockids:
             bkgen.request["bkids"] = blockids
         if users:
+            if isinstance(users, basestring):
+                users = [users]
+            # actual IPv6 addresses (anonymous users) are uppercase, but they
+            # have never a :: in the username (so those are registered users)
+            users = [user.upper() if is_IP(user) and '::' not in user else user
+                     for user in users]
             bkgen.request["bkusers"] = users
         return bkgen
 

-- 
To view, visit https://gerrit.wikimedia.org/r/195085
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iddfb2823cdfae16caa182ba7874beb5a08dd997b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to