PDF Output: Fix mangling of links

PDF Output: Fix links that point to URLs with query parameters being
mangled by the conversion process. Fixes #1197006 [Broken links in PDF in Adobe reader.](https://bugs.launchpad.net/calibre/+bug/1197006)
This commit is contained in:
Kovid Goyal 2013-07-03 14:42:08 +05:30
parent 541db88ebf
commit 36386d06cc

View File

@ -8,9 +8,8 @@ __copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import os import os
from future_builtins import map from urlparse import urlparse
from urlparse import urlparse, urlunparse from urllib2 import unquote
from urllib2 import quote, unquote
from calibre.ebooks.pdf.render.common import Array, Name, Dictionary, String from calibre.ebooks.pdf.render.common import Array, Name, Dictionary, String
@ -84,10 +83,6 @@ class Links(object):
action = Dictionary({ action = Dictionary({
'Type':Name('Action'), 'S':Name('URI'), 'Type':Name('Action'), 'S':Name('URI'),
}) })
parts = (x.encode('utf-8') if isinstance(x, type(u'')) else
x for x in purl)
url = urlunparse(map(quote, map(unquote,
parts))).decode('ascii')
action['URI'] = String(url) action['URI'] = String(url)
annot['A'] = action annot['A'] = action
if 'A' in annot or 'Dest' in annot: if 'A' in annot or 'Dest' in annot: