comparison core/management/commands/ssl_images.py @ 986:26de15fb5a80

Guard against bad image urls in ssl_images.
author Brian Neal <bgneal@gmail.com>
date Sun, 25 Oct 2015 14:47:29 -0500
parents 7db9037915c4
children 76525f5ac2b1
comparison
equal deleted inserted replaced
985:9b197dbba34b 986:26de15fb5a80
189 title = " ".join(src_parts[1:]) 189 title = " ".join(src_parts[1:])
190 alt = match.group(1) 190 alt = match.group(1)
191 191
192 new_src = None 192 new_src = None
193 if src: 193 if src:
194 r = urlparse.urlparse(src) 194 try:
195 r = urlparse.urlparse(src)
196 except ValueError:
197 return u'{bad image}'
198
195 if r.hostname in SG101_HOSTS: 199 if r.hostname in SG101_HOSTS:
196 new_src = r.path # convert to relative path 200 new_src = r.path # convert to relative path
197 elif r.scheme == 'http': 201 elif r.scheme == 'http':
198 # Try a few things to get this on ssl: 202 # Try a few things to get this on ssl:
199 new_src = convert_to_ssl(r) 203 new_src = convert_to_ssl(r)