From 2aa8f23d6c0b3ab585897d148c086899d80d02c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 4 Jul 2013 09:13:37 +0530 Subject: [PATCH] When parsing fields, handle escapes --- src/calibre/ebooks/docx/fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/ebooks/docx/fields.py b/src/calibre/ebooks/docx/fields.py index 9b0d053cd0..91dcd87596 100644 --- a/src/calibre/ebooks/docx/fields.py +++ b/src/calibre/ebooks/docx/fields.py @@ -37,7 +37,9 @@ scanner = re.Scanner([ def parse_hyperlink(raw, log): ans = {} last_option = None + raw = raw.replace('\\\\', '\x01').replace('\\"', '\x02') for token, token_type in scanner.scan(raw)[0]: + token = token.replace('\x01', '\\').replace('\x02', '"') if not ans: if token_type is not WORD: log('Invalid hyperlink, first token is not a URL (%s)' % raw)