mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02: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
|
||||
ext = name.split(".")[-1].lower()
|
||||
if ext in pics:
|
||||
return '<img src="%s">' % urllib.quote(name)
|
||||
return '<img src="%s">' % urllib.quote(name.encode("utf8"))
|
||||
else:
|
||||
anki.sound.play(name)
|
||||
return '[sound:%s]' % name
|
||||
|
@ -1097,8 +1097,8 @@ class EditorWebView(AnkiWebView):
|
|||
ext = url.split(".")[-1].lower()
|
||||
if ext not in pics and ext not in audio:
|
||||
return
|
||||
if url.lower().startswith("file:/"):
|
||||
url = urllib.quote(url, safe="/:")
|
||||
if url.lower().startswith("file://"):
|
||||
url = url.replace("#", "%23")
|
||||
# fetch it into a temporary folder
|
||||
self.editor.mw.progress.start(
|
||||
immediate=True, parent=self.editor.parentWindow)
|
||||
|
@ -1112,6 +1112,7 @@ class EditorWebView(AnkiWebView):
|
|||
finally:
|
||||
self.editor.mw.progress.finish()
|
||||
path = unicode(urllib2.unquote(url.encode("utf8")), "utf8")
|
||||
path = path.replace("#", "")
|
||||
path = namedtmp(os.path.basename(path))
|
||||
file = open(path, "wb")
|
||||
file.write(filecontents)
|
||||
|
|
Loading…
Reference in a new issue