compilebot icon indicating copy to clipboard operation
compilebot copied to clipboard

No repiy returned if the mension's permalink contains non-ascii character

Open nmtake opened this issue 7 years ago • 1 comments

It seems that compilebot doesn't reply for the compile request mention if the mention's permalink contains non-ascii character. For example:

  1. https://www.reddit.com/r/test/comments/6rov8e/compilebot_test/dl6nlsp/ - works as intended
  2. https://www.reddit.com/r/test/comments/6roxtv/compilebot_%E3%83%86%E3%82%B9%E3%83%88/dl6o5qp/ - doesn't work

I think urllib.quote(comment.permalink) (link) raises some error because PRAW's comment.permalink() returns unicode type which may contain non-parcent-encoded unicode characters and urllib.quote() doesn't accept unicode type:

>>> comment = next(reddit.get_unread())
>>> comment.permalink
u'https://www.reddit.com/r/:subreddit/comments/:submission_id/\u30c6\u30b9\u30c8\u30b9\u30ec\u30c3\u30c9/:comment_id'
>>> print comment.permalink
https://www.reddit.com/r/:subreddit/comments/:submission_id/テストスレッド/:comment_id
>>> from urllib import quote
>>> quote(comment.permalink)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1299, in quote
    return ''.join(map(quoter, s))
KeyError: u'\u30c6'

nmtake avatar Aug 05 '17 02:08 nmtake

Great catch, I'll figure out a way to fix this. ありがとうございます

renfredxh avatar Aug 17 '17 22:08 renfredxh