mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
don't try to download local image urls
This commit is contained in:
parent
9ccb21fe09
commit
402ec3a0b8
1 changed files with 8 additions and 3 deletions
|
@ -802,6 +802,12 @@ to a cloze type first, via Edit>Change Note Type."""))
|
||||||
# not a supported type; return link verbatim
|
# not a supported type; return link verbatim
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def isURL(self, s):
|
||||||
|
s = s.lower()
|
||||||
|
return (s.startswith("http://")
|
||||||
|
or s.startswith("https://")
|
||||||
|
or s.startswith("ftp://"))
|
||||||
|
|
||||||
def _retrieveURL(self, url):
|
def _retrieveURL(self, url):
|
||||||
"Download file into media folder and return local filename or None."
|
"Download file into media folder and return local filename or None."
|
||||||
# urllib is picky with local file links
|
# urllib is picky with local file links
|
||||||
|
@ -877,7 +883,7 @@ to a cloze type first, via Edit>Change Note Type."""))
|
||||||
try:
|
try:
|
||||||
if tag['src'].lower().startswith("file://"):
|
if tag['src'].lower().startswith("file://"):
|
||||||
tag['src'] = os.path.basename(tag['src'])
|
tag['src'] = os.path.basename(tag['src'])
|
||||||
if localize:
|
if localize and self.isURL(tag['src']):
|
||||||
# convert remote image links to local ones
|
# convert remote image links to local ones
|
||||||
fname = self.urlToFile(tag['src'])
|
fname = self.urlToFile(tag['src'])
|
||||||
if fname:
|
if fname:
|
||||||
|
@ -1097,10 +1103,9 @@ class EditorWebView(AnkiWebView):
|
||||||
|
|
||||||
def _processText(self, mime):
|
def _processText(self, mime):
|
||||||
txt = unicode(mime.text())
|
txt = unicode(mime.text())
|
||||||
l = txt.lower()
|
|
||||||
html = None
|
html = None
|
||||||
# if the user is pasting an image or sound link, convert it to local
|
# if the user is pasting an image or sound link, convert it to local
|
||||||
if l.startswith("http://") or l.startswith("https://") or l.startswith("file://"):
|
if self.editor.isURL(txt):
|
||||||
txt = txt.split("\r\n")[0]
|
txt = txt.split("\r\n")[0]
|
||||||
html = self.editor.urlToLink(txt)
|
html = self.editor.urlToLink(txt)
|
||||||
new = QMimeData()
|
new = QMimeData()
|
||||||
|
|
Loading…
Reference in a new issue