Remove pdf_ext module (closes #207561)

Addresses CVE-2014-1838.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset9c28b5b35b38
branchdefault
phasepublic
hiddenno
parent revision#32d122da03fc Use 'env' to run the interpreter.
child revision#2c4fd6f35674 shellutils: fix tempfile issue in Execute, and deprecate it
files modified by this revision
ChangeLog
README
pdf_ext.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1391421260 -3600
# Mon Feb 03 10:54:20 2014 +0100
# Node ID 9c28b5b35b38094353ff6c38be0701f9399b18cb
# Parent 32d122da03fc5d536d0ed6aa5f73fd775a24c935
Remove pdf_ext module (closes #207561)

Addresses CVE-2014-1838.

diff --git a/ChangeLog b/ChangeLog
@@ -1,9 +1,11 @@
1  ChangeLog for logilab.common
2  ============================
3 
4  --
5 +   * pdf_ext: removed, it had no known users (CVE-2014-1838)
6 +
7     * pytest: use 'env' to run the python interpreter
8 
9     * graph: ensure output is ordered on node and graph ids (#202314)
10 
11 
diff --git a/README b/README
@@ -121,12 +121,10 @@
12 
13  * `corbautils`, useful functions for use with the OmniORB_ CORBA library.
14 
15  * `hg`, some Mercurial_ utility functions.
16 
17 -* `pdf_ext`, pdf and fdf file manipulations, with pdftk.
18 -
19  * `pyro_ext`, some Pyro_ utility functions.
20 
21  * `sphinx_ext`, Sphinx_ plugin defining a `autodocstring` directive.
22 
23  * `vcgutils` , utilities functions to generate file readable with Georg Sander's
diff --git a/pdf_ext.py b/pdf_ext.py
@@ -1,111 +0,0 @@
24 -# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
25 -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
26 -#
27 -# This file is part of logilab-common.
28 -#
29 -# logilab-common is free software: you can redistribute it and/or modify it under
30 -# the terms of the GNU Lesser General Public License as published by the Free
31 -# Software Foundation, either version 2.1 of the License, or (at your option) any
32 -# later version.
33 -#
34 -# logilab-common is distributed in the hope that it will be useful, but WITHOUT
35 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
36 -# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
37 -# details.
38 -#
39 -# You should have received a copy of the GNU Lesser General Public License along
40 -# with logilab-common.  If not, see <http://www.gnu.org/licenses/>.
41 -"""Manipulate pdf and fdf files (pdftk recommended).
42 -
43 -Notes regarding pdftk, pdf forms and fdf files (form definition file)
44 -fields names can be extracted with:
45 -
46 -    pdftk orig.pdf generate_fdf output truc.fdf
47 -
48 -to merge fdf and pdf:
49 -
50 -    pdftk orig.pdf fill_form test.fdf output result.pdf [flatten]
51 -
52 -without flatten, one could further edit the resulting form.
53 -with flatten, everything is turned into text.
54 -
55 -
56 -
57 -
58 -"""
59 -__docformat__ = "restructuredtext en"
60 -# XXX seems very unix specific
61 -# TODO: check availability of pdftk at import
62 -
63 -
64 -import os
65 -
66 -HEAD="""%FDF-1.2
67 -%\xE2\xE3\xCF\xD3
68 -1 0 obj
69 -<<
70 -/FDF
71 -<<
72 -/Fields [
73 -"""
74 -
75 -TAIL="""]
76 ->>
77 ->>
78 -endobj
79 -trailer
80 -
81 -<<
82 -/Root 1 0 R
83 ->>
84 -%%EOF
85 -"""
86 -
87 -def output_field( f ):
88 -    return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] )
89 -
90 -def extract_keys(lines):
91 -    keys = []
92 -    for line in lines:
93 -        if line.startswith('/V'):
94 -            pass #print 'value',line
95 -        elif line.startswith('/T'):
96 -            key = line[7:-2]
97 -            key = ''.join(key.split('\x00'))
98 -            keys.append( key )
99 -    return keys
100 -
101 -def write_field(out, key, value):
102 -    out.write("<<\n")
103 -    if value:
104 -        out.write("/V (%s)\n" %value)
105 -    else:
106 -        out.write("/V /\n")
107 -    out.write("/T (%s)\n" % output_field(key) )
108 -    out.write(">> \n")
109 -
110 -def write_fields(out, fields):
111 -    out.write(HEAD)
112 -    for (key, value, comment) in fields:
113 -        write_field(out, key, value)
114 -        write_field(out, key+"a", value) # pour copie-carbone sur autres pages
115 -    out.write(TAIL)
116 -
117 -def extract_keys_from_pdf(filename):
118 -    # what about using 'pdftk filename dump_data_fields' and parsing the output ?
119 -    os.system('pdftk %s generate_fdf output /tmp/toto.fdf' % filename)
120 -    lines = file('/tmp/toto.fdf').readlines()
121 -    return extract_keys(lines)
122 -
123 -
124 -def fill_pdf(infile, outfile, fields):
125 -    write_fields(file('/tmp/toto.fdf', 'w'), fields)
126 -    os.system('pdftk %s fill_form /tmp/toto.fdf output %s flatten' % (infile, outfile))
127 -
128 -def testfill_pdf(infile, outfile):
129 -    keys = extract_keys_from_pdf(infile)
130 -    fields = []
131 -    for key in keys:
132 -        fields.append( (key, key, '') )
133 -    fill_pdf(infile, outfile, fields)
134 -