Skip to content

Commit 85986b8

Browse files
committed
handle unicode in query
1 parent 1cfd5cc commit 85986b8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

atwiki/uri.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
try:
66
# Python 3
77
import urllib.parse as urlparse
8+
from urllib.parse import quote as urlquote
89
except:
910
# Python 2
1011
import urlparse
12+
from urllib import quote as urlquote
1113

1214
import os.path
1315

@@ -51,12 +53,12 @@ def get_absolute_uri(self, uripart):
5153
def search(self, keyword=None, is_and=True):
5254
if keyword is not None:
5355
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)
5557
else:
5658
return '{0}/search'.format(self._base)
5759

5860
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)
6062

6163
def new(self):
6264
return '{0}/new'.format(self._base)
@@ -108,7 +110,7 @@ def diff(self, page_id):
108110
return '{0}/diffx/{1}.html'.format(self._base, page_id)
109111

110112
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))
112114

113115
def edit(self, page_id, menu=True):
114116
mode = 'editx' if menu else 'editxx'

0 commit comments

Comments
 (0)