mirror of
https://github.com/ankitects/anki.git
synced 2025-11-10 22:57:11 -05:00
we shouldn't encode to utf8 when unquoting
This commit is contained in:
parent
d53346d783
commit
2dd28d86a2
1 changed files with 5 additions and 6 deletions
|
|
@ -222,17 +222,16 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def escapeImages(self, string, unescape=False):
|
def escapeImages(self, string, unescape=False):
|
||||||
if unescape:
|
|
||||||
fn = urllib.unquote
|
|
||||||
else:
|
|
||||||
fn = urllib.quote
|
|
||||||
def repl(match):
|
def repl(match):
|
||||||
tag = match.group(0)
|
tag = match.group(0)
|
||||||
fname = match.group("fname")
|
fname = match.group("fname")
|
||||||
if re.match("(https?|ftp)://", fname):
|
if re.match("(https?|ftp)://", fname):
|
||||||
return tag
|
return tag
|
||||||
return tag.replace(
|
if unescape:
|
||||||
fname, fn(fname.encode("utf-8")))
|
txt = urllib.unquote(fname)
|
||||||
|
else:
|
||||||
|
txt = urllib.quote(fname.encode("utf-8"))
|
||||||
|
return tag.replace(fname, txt)
|
||||||
for reg in self.imgRegexps:
|
for reg in self.imgRegexps:
|
||||||
string = re.sub(reg, repl, string)
|
string = re.sub(reg, repl, string)
|
||||||
return string
|
return string
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue