diff --git a/zds/tutorial/factories.py b/zds/tutorial/factories.py index 1ec34ca23d..c066921153 100644 --- a/zds/tutorial/factories.py +++ b/zds/tutorial/factories.py @@ -28,6 +28,7 @@ u'\nExemple d\'image ![Image inexistante](http://blog.science-infuse.fr/public/inv_souris.jpg)' u'\nExemple de gif ![](http://corigif.free.fr/oiseau/img/oiseau_004.gif)' u'\nExemple de gif inexistant ![](http://corigif.free.fr/oiseau/img/ironman.gif)' +u'Une image de type wikipedia qui fait tomber des tests ![](https://s.qwant.com/thumbr/?u=http%3A%2F%2Fwww.blogoergosum.com%2Fwp-content%2Fuploads%2F2010%2F02%2Fwikipedia-logo.jpg&h=338&w=600)' u'\n Attention les tests ne doivent pas crasher ' u'qu\'un sujet abandonné !') diff --git a/zds/tutorial/views.py b/zds/tutorial/views.py index e513ab9456..e6f11c6602 100644 --- a/zds/tutorial/views.py +++ b/zds/tutorial/views.py @@ -4,7 +4,7 @@ from datetime import datetime from operator import attrgetter from urllib import urlretrieve -from urlparse import urlparse +from urlparse import urlparse, parse_qs try: import ujson as json_reader except: @@ -2782,9 +2782,11 @@ def get_url_images(md_text, pt): imgs = re.findall(regex, md_text) for img in imgs: - # decompose images - + # decompose images parse_object = urlparse(img[1]) + if parse_object.query!='': + resp = parse_qs(urlparse(img[1]).query, keep_blank_values=True) + parse_object = urlparse(resp["u"][0]) # if link is http type if parse_object.scheme in ["http", "https", "ftp"] or \ @@ -2838,6 +2840,9 @@ def sub_urlimg(g): start = g.group("start") url = g.group("url") parse_object = urlparse(url) + if parse_object.query!='': + resp = parse_qs(urlparse(url).query, keep_blank_values=True) + parse_object = urlparse(resp["u"][0]) (filepath, filename) = os.path.split(parse_object.path) ext = filename.split(".")[-1] if ext == "gif":