Skip to content

Commit

Permalink
correction des images demandant une requete
Browse files Browse the repository at this point in the history
  • Loading branch information
firm1 committed Aug 17, 2014
1 parent 12ad16f commit 46cebf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions zds/tutorial/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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é !')

Expand Down
11 changes: 8 additions & 3 deletions zds/tutorial/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 46cebf1

Please sign in to comment.