|
5 | 5 | try: |
6 | 6 | # Python 3 |
7 | 7 | import urllib.parse as urlparse |
| 8 | + from urllib.parse import quote as urlquote |
8 | 9 | except: |
9 | 10 | # Python 2 |
10 | 11 | import urlparse |
| 12 | + from urllib import quote as urlquote |
11 | 13 |
|
12 | 14 | import os.path |
13 | 15 |
|
@@ -51,12 +53,12 @@ def get_absolute_uri(self, uripart): |
51 | 53 | def search(self, keyword=None, is_and=True): |
52 | 54 | if keyword is not None: |
53 | 55 | andor = 'and' if is_and else 'or' |
54 | | - return '{0}/?cmd=search&keyword={1}&andor={2}'.format(self._base, keyword, andor) |
| 56 | + return '{0}/?cmd=search&keyword={1}&andor={2}'.format(self._base, urlquote(keyword), andor) |
55 | 57 | else: |
56 | 58 | return '{0}/search'.format(self._base) |
57 | 59 |
|
58 | 60 | def tag(self, tag_name='', index=0): |
59 | | - return '{0}/tag/{1}?p={2}'.format(self._base, tag_name, index) |
| 61 | + return '{0}/tag/{1}?p={2}'.format(self._base, urlquote(tag_name), index) |
60 | 62 |
|
61 | 63 | def new(self): |
62 | 64 | return '{0}/new'.format(self._base) |
@@ -108,7 +110,7 @@ def diff(self, page_id): |
108 | 110 | return '{0}/diffx/{1}.html'.format(self._base, page_id) |
109 | 111 |
|
110 | 112 | def word(self, page_id, keyword): |
111 | | - return '{0}/?cmd=word&pageid={1}&word={2}&type=normal'.format(self._base, page_id, keyword) |
| 113 | + return '{0}/?cmd=word&pageid={1}&word={2}&type=normal'.format(self._base, page_id, urlquote(keyword)) |
112 | 114 |
|
113 | 115 | def edit(self, page_id, menu=True): |
114 | 116 | mode = 'editx' if menu else 'editxx' |
|
0 commit comments