forked from solderpunk/AV-98
fixing a crash with data:image svg
This commit is contained in:
parent
af65662f0f
commit
7bcd0e2af5
|
@ -9,6 +9,7 @@
|
||||||
- Accept "localhost" as a valid URL
|
- Accept "localhost" as a valid URL
|
||||||
- Better feedback when --sync an URL which is streaming
|
- Better feedback when --sync an URL which is streaming
|
||||||
- Removed cgi dependency (soon deprecated)
|
- Removed cgi dependency (soon deprecated)
|
||||||
|
- Fix: crash with some svg data:image (which are now ignored)
|
||||||
- Fix images from "full" mode not being downloaded
|
- Fix images from "full" mode not being downloaded
|
||||||
- Fix a crash when ls on empty page (thanks Marty Oehme)
|
- Fix a crash when ls on empty page (thanks Marty Oehme)
|
||||||
- Fix: A variable was not initialised without python-cryptography
|
- Fix: A variable was not initialised without python-cryptography
|
||||||
|
|
27
offpunk.py
27
offpunk.py
|
@ -1582,7 +1582,10 @@ class GeminiItem():
|
||||||
toreturn.append(newgi)
|
toreturn.append(newgi)
|
||||||
elif url and mode != "links_only" and url.startswith("data:image/"):
|
elif url and mode != "links_only" and url.startswith("data:image/"):
|
||||||
imgurl,imgdata = looks_like_base64(url,self.url)
|
imgurl,imgdata = looks_like_base64(url,self.url)
|
||||||
toreturn.append(GeminiItem(imgurl))
|
if imgurl:
|
||||||
|
toreturn.append(GeminiItem(imgurl))
|
||||||
|
else:
|
||||||
|
toreturn.append(None)
|
||||||
else:
|
else:
|
||||||
# We must include a None item to keep the link count valid
|
# We must include a None item to keep the link count valid
|
||||||
toreturn.append(None)
|
toreturn.append(None)
|
||||||
|
@ -1860,12 +1863,18 @@ def looks_like_url(word):
|
||||||
def looks_like_base64(src,baseurl):
|
def looks_like_base64(src,baseurl):
|
||||||
imgdata = None
|
imgdata = None
|
||||||
imgname = src
|
imgname = src
|
||||||
if src and src.startswith("data:image/") and ";base64," in src:
|
if src and src.startswith("data:image/"):
|
||||||
splitted = src.split(";base64,")
|
if ";base64," in src:
|
||||||
extension = splitted[0].strip("data:image/")[:3]
|
splitted = src.split(";base64,")
|
||||||
imgdata = splitted[1]
|
extension = splitted[0].strip("data:image/")[:3]
|
||||||
imgname = imgdata[:20] + "." + extension
|
imgdata = splitted[1]
|
||||||
imgurl = urllib.parse.urljoin(baseurl, imgname)
|
imgname = imgdata[:20] + "." + extension
|
||||||
|
imgurl = urllib.parse.urljoin(baseurl, imgname)
|
||||||
|
else:
|
||||||
|
#We can’t handle other data:image such as svg for now
|
||||||
|
imgurl = None
|
||||||
|
else:
|
||||||
|
imgurl = urllib.parse.urljoin(baseurl, imgname)
|
||||||
return imgurl,imgdata
|
return imgurl,imgdata
|
||||||
|
|
||||||
class UserAbortException(Exception):
|
class UserAbortException(Exception):
|
||||||
|
@ -2026,10 +2035,10 @@ class GeminiClient(cmd.Cmd):
|
||||||
storing the response in a temporary file, choosing
|
storing the response in a temporary file, choosing
|
||||||
and calling a handler program, and updating the history.
|
and calling a handler program, and updating the history.
|
||||||
Nothing is returned."""
|
Nothing is returned."""
|
||||||
if not mode:
|
|
||||||
mode = gi.last_mode
|
|
||||||
if not gi:
|
if not gi:
|
||||||
return
|
return
|
||||||
|
if not mode:
|
||||||
|
mode = gi.last_mode
|
||||||
# Don't try to speak to servers running other protocols
|
# Don't try to speak to servers running other protocols
|
||||||
elif gi.scheme == "mailto":
|
elif gi.scheme == "mailto":
|
||||||
if handle and not self.sync_only:
|
if handle and not self.sync_only:
|
||||||
|
|
Loading…
Reference in New Issue