forked from kovidgoyal/calibre
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDF metadata: Do not crash when reading malformed PDF files
- Loading branch information
1 parent
d805a93
commit e2148e8
Showing
19 changed files
with
86 additions
and
2,552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
__copyright__ = '2009, Kovid Goyal <[email protected]>' | ||
__docformat__ = 'restructuredtext en' | ||
|
||
import os, socket, struct, subprocess, glob | ||
import os, socket, struct, subprocess | ||
from distutils.spawn import find_executable | ||
|
||
from PyQt4 import pyqtconfig | ||
|
@@ -84,7 +84,6 @@ def consolidate(envvar, default): | |
ft_libs = [] | ||
jpg_libs = [] | ||
jpg_lib_dirs = [] | ||
poppler_objs = [] | ||
fc_inc = '/usr/include/fontconfig' | ||
fc_lib = '/usr/lib' | ||
podofo_inc = '/usr/include/podofo' | ||
|
@@ -114,12 +113,7 @@ def consolidate(envvar, default): | |
jpg_libs = ['jpeg'] | ||
ft_lib_dirs = [sw_lib_dir] | ||
ft_libs = ['freetype'] | ||
poppler_inc_dirs = consolidate('POPPLER_INC_DIR', | ||
r'%s\poppler;%s'%(sw_inc_dir, sw_inc_dir)) | ||
|
||
poppler_lib_dirs = consolidate('POPPLER_LIB_DIR', sw_lib_dir) | ||
popplerqt4_lib_dirs = poppler_lib_dirs | ||
poppler_libs = ['poppler'] | ||
magick_inc_dirs = [os.path.join(prefix, 'build', 'ImageMagick-6.7.6')] | ||
magick_lib_dirs = [os.path.join(magick_inc_dirs[0], 'VisualMagick', 'lib')] | ||
magick_libs = ['CORE_RL_wand_', 'CORE_RL_magick_'] | ||
|
@@ -128,13 +122,6 @@ def consolidate(envvar, default): | |
elif isosx: | ||
fc_inc = '/sw/include/fontconfig' | ||
fc_lib = '/sw/lib' | ||
poppler = glob.glob('/sw/build/poppler-*')[-1] | ||
poppler_inc_dirs = consolidate('POPPLER_INC_DIR', | ||
'{0}/poppler:{0}'.format(poppler)) | ||
poppler_lib_dirs = consolidate('POPPLER_LIB_DIR', | ||
'/sw/lib') | ||
poppler_libs = ['poppler'] | ||
popplerqt4_lib_dirs = poppler_lib_dirs | ||
podofo_inc = '/sw/podofo' | ||
podofo_lib = '/sw/lib' | ||
magick_inc_dirs = consolidate('MAGICK_INC', | ||
|
@@ -147,22 +134,15 @@ def consolidate(envvar, default): | |
png_libs = ['png12'] | ||
else: | ||
# Include directories | ||
poppler_inc_dirs = pkgconfig_include_dirs('poppler', | ||
'POPPLER_INC_DIR', '/usr/include/poppler') | ||
png_inc_dirs = pkgconfig_include_dirs('libpng', 'PNG_INC_DIR', | ||
'/usr/include') | ||
magick_inc_dirs = pkgconfig_include_dirs('MagickWand', 'MAGICK_INC', '/usr/include/ImageMagick') | ||
|
||
# Library directories | ||
poppler_lib_dirs = popplerqt4_lib_dirs = pkgconfig_lib_dirs('poppler', 'POPPLER_LIB_DIR', | ||
'/usr/lib') | ||
png_lib_dirs = pkgconfig_lib_dirs('libpng', 'PNG_LIB_DIR', '/usr/lib') | ||
magick_lib_dirs = pkgconfig_lib_dirs('MagickWand', 'MAGICK_LIB', '/usr/lib') | ||
|
||
# Libraries | ||
poppler_libs = pkgconfig_libs('poppler', '', '') | ||
if not poppler_libs: | ||
poppler_libs = ['poppler'] | ||
magick_libs = pkgconfig_libs('MagickWand', '', '') | ||
if not magick_libs: | ||
magick_libs = ['MagickWand', 'MagickCore'] | ||
|
@@ -176,26 +156,6 @@ def consolidate(envvar, default): | |
'Try setting the FC_INC_DIR and FC_LIB_DIR environment ' | ||
'variables.') | ||
|
||
|
||
poppler_error = None | ||
poppler_cflags = ['-DPNG_SKIP_SETJMP_CHECK'] if islinux else [] | ||
if not poppler_inc_dirs or not os.path.exists( | ||
os.path.join(poppler_inc_dirs[0], 'OutputDev.h')): | ||
poppler_error = \ | ||
('Poppler not found on your system. Various PDF related', | ||
' functionality will not work. Use the POPPLER_INC_DIR and', | ||
' POPPLER_LIB_DIR environment variables. calibre requires ' | ||
' the poppler XPDF headers. If your distro does not ' | ||
' include them you will have to re-compile poppler ' | ||
' by hand with --enable-xpdf-headers') | ||
else: | ||
lh = os.path.join(poppler_inc_dirs[0], 'Link.h') | ||
if 'class AnnotLink' not in open(lh, 'rb').read(): | ||
poppler_cflags.append('-DPOPPLER_OLD_LINK_TYPE') | ||
ph = os.path.join(poppler_inc_dirs[0], 'Page.h') | ||
if 'getLinks(Catalog' in open(ph, 'rb').read(): | ||
poppler_cflags.append('-DPOPPLER_PRE_20') | ||
|
||
magick_error = None | ||
if not magick_inc_dirs or not os.path.exists(os.path.join(magick_inc_dirs[0], | ||
'wand')): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.