Merge pull request #255 from gmcmanus/master

Properly escape pasted URLs
This commit is contained in:
Damien Elmes 2018-10-04 17:44:13 +10:00 committed by GitHub
commit a119afed6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -582,7 +582,7 @@ to a cloze type first, via Edit>Change Note Type."""))
def urlToLink(self, url): def urlToLink(self, url):
fname = self.urlToFile(url) fname = self.urlToFile(url)
if not fname: if not fname:
return url return None
return self.fnameToLink(fname) return self.fnameToLink(fname)
def fnameToLink(self, fname): def fnameToLink(self, fname):
@ -915,8 +915,10 @@ class EditorWebView(AnkiWebView):
# 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 self.editor.isURL(txt): if self.editor.isURL(txt):
txt = txt.split("\r\n")[0] url = txt.split("\r\n")[0]
return self.editor.urlToLink(txt) link = self.editor.urlToLink(url)
if link:
return link
# normal text; convert it to HTML # normal text; convert it to HTML
txt = html.escape(txt) txt = html.escape(txt)