Ricordisamoa has uploaded a new change for review.
https://gerrit.wikimedia.org/r/178647
Change subject: Remove FilePage.getFileMd5Sum()
......................................................................
Remove FilePage.getFileMd5Sum()
It has been marked as deprecated since its addition by Russell Blau
back in 2008 (c636fd0db2b41a618bcbcffc02c126dd96cc0d64).
The MD5 algorithm is widely known as being insecure and has been
almost completely replaced by more advanced alternatives such as SHA1.
Its implementation as FilePage method is not covered by any tests
and thus it's very prone to bugs.
The only bundled script that was using it, nowcommons.py, has been
updated with commit 1d0f94cdcc61b30b78d3efd075dfdd46ddcfabcc to use
.getFileSHA1Sum() instead.
Related documentation in README-conversion.txt and compat2core.py
has been updated.
Change-Id: I448a3c7df66a2d35a6cb17b5d853fa94047e24d1
---
M README-conversion.txt
M pywikibot/page.py
M scripts/maintenance/compat2core.py
3 files changed, 3 insertions(+), 17 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/47/178647/1
diff --git a/README-conversion.txt b/README-conversion.txt
index dd6c1c7..a5df639 100644
--- a/README-conversion.txt
+++ b/README-conversion.txt
@@ -112,8 +112,8 @@
=== FilePage objects ===
The old ImagePage class has been renamed into FilePage.
-For FilePage objects, the getFileMd5Sum() method is deprecated; it is
-recommended to replace it with getFileSHA1Sum(), because MediaWiki now
+For FilePage objects, the getFileMd5Sum() method has been removed;
+it should be replaced with getFileSHA1Sum(), because MediaWiki now
stores the SHA1 hash of images.
=== Category objects ===
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 192d3e1..0b2d29c 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -22,7 +22,6 @@
import re
import unicodedata
import collections
-import hashlib
try:
from collections import OrderedDict
@@ -1904,19 +1903,6 @@
else:
return self.fileUrl().startswith(
'https://upload.wikimedia.org/wikipedia/commons/')
-
- @deprecated("FilePage.getFileSHA1Sum()")
- def getFileMd5Sum(self):
- """Return image file's MD5 checksum."""
-# FIXME: MD5 might be performed on incomplete file due to server disconnection
-# (see bug #1795683).
- f = urlopen(self.fileUrl())
- # TODO: check whether this needs a User-Agent header added
- h = hashlib.md5()
- h.update(f.read())
- md5Checksum = h.hexdigest()
- f.close()
- return md5Checksum
def getFileSHA1Sum(self):
"""Return the file's SHA1 checksum."""
diff --git a/scripts/maintenance/compat2core.py
b/scripts/maintenance/compat2core.py
index 5311aab..ce543c3 100644
--- a/scripts/maintenance/compat2core.py
+++ b/scripts/maintenance/compat2core.py
@@ -97,7 +97,7 @@
'User.contributions() returns a pywikibot.Timestamp object instead of a\n'
'MediaWiki one'),
('.getFileMd5Sum(',
- 'FilePage.getFileMd5Sum() is deprecated should be replaced by '
+ 'FilePage.getFileMd5Sum() has been removed and should be replaced by '
'getFileSHA1Sum()'),
(' wikipedia.',
'"wikipedia" library has been changed to "pywikibot".'),
--
To view, visit https://gerrit.wikimedia.org/r/178647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I448a3c7df66a2d35a6cb17b5d853fa94047e24d1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits