mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
- treat # specially instead of quoting entire string, as urllib unfortunately can't handle utf8 quoted text - make sure we pass utf8 to quote() in _addMedia()
This commit is contained in:
parent
403a53cebf
commit
93717df30b
1 changed files with 4 additions and 3 deletions
|
@ -817,7 +817,7 @@ to a cloze type first, via Edit>Change Note Type."""))
|
||||||
# return a local html link
|
# return a local html link
|
||||||
ext = name.split(".")[-1].lower()
|
ext = name.split(".")[-1].lower()
|
||||||
if ext in pics:
|
if ext in pics:
|
||||||
return '<img src="%s">' % urllib.quote(name)
|
return '<img src="%s">' % urllib.quote(name.encode("utf8"))
|
||||||
else:
|
else:
|
||||||
anki.sound.play(name)
|
anki.sound.play(name)
|
||||||
return '[sound:%s]' % name
|
return '[sound:%s]' % name
|
||||||
|
@ -1097,8 +1097,8 @@ class EditorWebView(AnkiWebView):
|
||||||
ext = url.split(".")[-1].lower()
|
ext = url.split(".")[-1].lower()
|
||||||
if ext not in pics and ext not in audio:
|
if ext not in pics and ext not in audio:
|
||||||
return
|
return
|
||||||
if url.lower().startswith("file:/"):
|
if url.lower().startswith("file://"):
|
||||||
url = urllib.quote(url, safe="/:")
|
url = url.replace("#", "%23")
|
||||||
# fetch it into a temporary folder
|
# fetch it into a temporary folder
|
||||||
self.editor.mw.progress.start(
|
self.editor.mw.progress.start(
|
||||||
immediate=True, parent=self.editor.parentWindow)
|
immediate=True, parent=self.editor.parentWindow)
|
||||||
|
@ -1112,6 +1112,7 @@ class EditorWebView(AnkiWebView):
|
||||||
finally:
|
finally:
|
||||||
self.editor.mw.progress.finish()
|
self.editor.mw.progress.finish()
|
||||||
path = unicode(urllib2.unquote(url.encode("utf8")), "utf8")
|
path = unicode(urllib2.unquote(url.encode("utf8")), "utf8")
|
||||||
|
path = path.replace("#", "")
|
||||||
path = namedtmp(os.path.basename(path))
|
path = namedtmp(os.path.basename(path))
|
||||||
file = open(path, "wb")
|
file = open(path, "wb")
|
||||||
file.write(filecontents)
|
file.write(filecontents)
|
||||||
|
|
Loading…
Reference in a new issue