imgur: Restrict URL to imgur domains

Otherwise it would crash any pastoob get!
This commit is contained in:
Laurent Bachelier 2014-10-10 23:25:35 +02:00
commit 99b4ce7d58

View file

@ -23,6 +23,7 @@ from weboob.capabilities.paste import CapPaste, BasePaste
from weboob.tools.capabilities.paste import image_mime
from weboob.capabilities.base import StringField
from weboob.deprecated.browser import StandardBrowser
from weboob.deprecated.browser.decorators import check_url
from urllib import urlencode
import re
@ -91,6 +92,7 @@ class ImgurModule(Module, CapPaste):
paste.id = json['data']['id']
paste.delete_url = 'https://api.imgur.com/3/image/%s' % json['data']['deletehash']
@check_url('https?://(?:[a-z]+\.)?imgur.com/')
def get_paste(self, id):
paste = ImgPaste(id)
paste.contents = self.browser.readurl(paste.raw_url).encode('base64')