jenkins-bot has submitted this change and it was merged.

Change subject: Allow non-urlencoded permalink
......................................................................


Allow non-urlencoded permalink

With browsers increasing their support for non-ascii urls the need
for the urlencode of the title is not always guaranteed. Adding an
optional parameter to permalink ensures this option becomes
available.

Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
(cherry picked from commit 7f12117a61ab3df5c1ee7f6deb718e66fde1a200)
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/page.py b/pywikibot/page.py
index a78ed9a..6f72ded 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -418,16 +418,20 @@
         # TODO: what about redirects, errors?
         return self._revisions[oldid].text
 
-    def permalink(self, oldid=None):
+    def permalink(self, oldid=None, percent_encoded=True):
         """Return the permalink URL of an old revision of this page.
 
         @param oldid: The revid of the revision desired.
 
         """
+        if percent_encoded:
+            title = self.title(asUrl=True)
+        else:
+            title = self.title(asUrl=False).replace(' ', '_')
         return "//%s%s/index.php?title=%s&oldid=%s" \
                % (self.site.hostname(),
                   self.site.scriptpath(),
-                  self.title(asUrl=True),
+                  title,
                   (oldid if oldid is not None else self.latest_revision_id))
 
     @property

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7a5edd89347c6d1462fb220fd514469ac14dd83
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Lokal Profil <lokal.pro...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.pro...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to