1 |
commit: 0bd80b2412af7bd1143f9bb9a3426ebdfab5c333 |
2 |
Author: Justin Lecher <jlec <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Oct 30 11:14:00 2015 +0000 |
4 |
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Oct 30 12:03:49 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0bd80b24 |
7 |
|
8 |
dev-python/pygments: Backport fix for shell injection |
9 |
|
10 |
Gentoo-Bug: https://bugs.gentoo.org/show_bug.cgi?id=564478 |
11 |
|
12 |
Package-Manager: portage-2.2.23 |
13 |
Signed-off-by: Justin Lecher <jlec <AT> gentoo.org> |
14 |
|
15 |
.../files/2.0.2-shell-injection-backport.patch | 29 +++++++++++ |
16 |
.../files/2.0.2-shell-injection-backport2.patch | 56 +++++++++++++++++++++ |
17 |
dev-python/pygments/metadata.xml | 2 +- |
18 |
dev-python/pygments/pygments-2.0.2-r1.ebuild | 57 ++++++++++++++++++++++ |
19 |
4 files changed, 143 insertions(+), 1 deletion(-) |
20 |
|
21 |
diff --git a/dev-python/pygments/files/2.0.2-shell-injection-backport.patch b/dev-python/pygments/files/2.0.2-shell-injection-backport.patch |
22 |
new file mode 100644 |
23 |
index 0000000..0a23adc |
24 |
--- /dev/null |
25 |
+++ b/dev-python/pygments/files/2.0.2-shell-injection-backport.patch |
26 |
@@ -0,0 +1,29 @@ |
27 |
+# HG changeset patch |
28 |
+# User Javantea <jvoss@××××××.com> |
29 |
+# Date 1443460403 25200 |
30 |
+# Node ID 6b4baae517b6aaff7142e66f1dbadf7b9b871f61 |
31 |
+# Parent 655dbebddc23943b8047b3c139c51c22ef18fd91 |
32 |
+Fix Shell Injection in FontManager._get_nix_font_path |
33 |
+ |
34 |
+diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py |
35 |
+--- a/pygments/formatters/img.py |
36 |
++++ b/pygments/formatters/img.py |
37 |
+@@ -10,6 +10,7 @@ |
38 |
+ """ |
39 |
+ |
40 |
+ import sys |
41 |
++import shlex |
42 |
+ |
43 |
+ from pygments.formatter import Formatter |
44 |
+ from pygments.util import get_bool_opt, get_int_opt, get_list_opt, \ |
45 |
+@@ -79,8 +80,8 @@ |
46 |
+ from commands import getstatusoutput |
47 |
+ except ImportError: |
48 |
+ from subprocess import getstatusoutput |
49 |
+- exit, out = getstatusoutput('fc-list "%s:style=%s" file' % |
50 |
+- (name, style)) |
51 |
++ exit, out = getstatusoutput('fc-list %s file' % |
52 |
++ shlex.quote("%s:style=%s" % (name, style))) |
53 |
+ if not exit: |
54 |
+ lines = out.splitlines() |
55 |
+ if lines: |
56 |
|
57 |
diff --git a/dev-python/pygments/files/2.0.2-shell-injection-backport2.patch b/dev-python/pygments/files/2.0.2-shell-injection-backport2.patch |
58 |
new file mode 100644 |
59 |
index 0000000..78bf447 |
60 |
--- /dev/null |
61 |
+++ b/dev-python/pygments/files/2.0.2-shell-injection-backport2.patch |
62 |
@@ -0,0 +1,56 @@ |
63 |
+# HG changeset patch |
64 |
+# User Tim Hatch <tim@××××××××.com> |
65 |
+# Date 1445007300 25200 |
66 |
+# Node ID 0036ab1c99e256298094505e5e92fdacdfc5b0a8 |
67 |
+# Parent c0c0d4049a7c325cd69b764c6ceb7747d319212d |
68 |
+Avoid the shell entirely when finding fonts. |
69 |
+ |
70 |
+Manually tested on OS X. |
71 |
+ |
72 |
+diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py |
73 |
+--- a/pygments/formatters/img.py |
74 |
++++ b/pygments/formatters/img.py |
75 |
+@@ -10,12 +10,13 @@ |
76 |
+ """ |
77 |
+ |
78 |
+ import sys |
79 |
+-import shlex |
80 |
+ |
81 |
+ from pygments.formatter import Formatter |
82 |
+ from pygments.util import get_bool_opt, get_int_opt, get_list_opt, \ |
83 |
+ get_choice_opt, xrange |
84 |
+ |
85 |
++import subprocess |
86 |
++ |
87 |
+ # Import this carefully |
88 |
+ try: |
89 |
+ from PIL import Image, ImageDraw, ImageFont |
90 |
+@@ -76,14 +77,11 @@ |
91 |
+ self._create_nix() |
92 |
+ |
93 |
+ def _get_nix_font_path(self, name, style): |
94 |
+- try: |
95 |
+- from commands import getstatusoutput |
96 |
+- except ImportError: |
97 |
+- from subprocess import getstatusoutput |
98 |
+- exit, out = getstatusoutput('fc-list %s file' % |
99 |
+- shlex.quote("%s:style=%s" % (name, style))) |
100 |
+- if not exit: |
101 |
+- lines = out.splitlines() |
102 |
++ proc = subprocess.Popen(['fc-list', "%s:style=%s" % (name, style), 'file'], |
103 |
++ stdout=subprocess.PIPE, stderr=None) |
104 |
++ stdout, _ = proc.communicate() |
105 |
++ if proc.returncode == 0: |
106 |
++ lines = stdout.splitlines() |
107 |
+ if lines: |
108 |
+ path = lines[0].strip().strip(':') |
109 |
+ return path |
110 |
+@@ -198,7 +196,7 @@ |
111 |
+ bold and italic fonts will be generated. This really should be a |
112 |
+ monospace font to look sane. |
113 |
+ |
114 |
+- Default: "Bitstream Vera Sans Mono" |
115 |
++ Default: "Bitstream Vera Sans Mono" on Windows, Courier New on *nix |
116 |
+ |
117 |
+ `font_size` |
118 |
+ The font size in points to be used. |
119 |
|
120 |
diff --git a/dev-python/pygments/metadata.xml b/dev-python/pygments/metadata.xml |
121 |
index 10b24d2..f91efd2 100644 |
122 |
--- a/dev-python/pygments/metadata.xml |
123 |
+++ b/dev-python/pygments/metadata.xml |
124 |
@@ -1,4 +1,4 @@ |
125 |
-<?xml version='1.0' encoding='UTF-8'?> |
126 |
+<?xml version="1.0" encoding="UTF-8"?> |
127 |
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
128 |
<pkgmetadata> |
129 |
<herd>python</herd> |
130 |
|
131 |
diff --git a/dev-python/pygments/pygments-2.0.2-r1.ebuild b/dev-python/pygments/pygments-2.0.2-r1.ebuild |
132 |
new file mode 100644 |
133 |
index 0000000..3ee352b |
134 |
--- /dev/null |
135 |
+++ b/dev-python/pygments/pygments-2.0.2-r1.ebuild |
136 |
@@ -0,0 +1,57 @@ |
137 |
+# Copyright 1999-2015 Gentoo Foundation |
138 |
+# Distributed under the terms of the GNU General Public License v2 |
139 |
+# $Id$ |
140 |
+ |
141 |
+EAPI=5 |
142 |
+ |
143 |
+PYTHON_COMPAT=( python2_7 python3_{3,4,5} pypy pypy3 ) |
144 |
+ |
145 |
+inherit distutils-r1 bash-completion-r1 vcs-snapshot |
146 |
+ |
147 |
+MY_PN="Pygments" |
148 |
+MY_P="${MY_PN}-${PV}" |
149 |
+ |
150 |
+DESCRIPTION="Pygments is a syntax highlighting package written in Python" |
151 |
+HOMEPAGE="http://pygments.org/ https://pypi.python.org/pypi/Pygments" |
152 |
+SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz" |
153 |
+ |
154 |
+LICENSE="BSD" |
155 |
+SLOT="0" |
156 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" |
157 |
+IUSE="doc test" |
158 |
+ |
159 |
+RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]" |
160 |
+DEPEND="${RDEPEND} |
161 |
+ doc? ( dev-python/sphinx[${PYTHON_USEDEP}] ) |
162 |
+ test? ( |
163 |
+ dev-python/nose[${PYTHON_USEDEP}] |
164 |
+ virtual/ttf-fonts )" |
165 |
+# dev-texlive/texlive-latexrecommended |
166 |
+# Removing / commenting out this dep. I can find no mention of it in tests other than |
167 |
+# importing pygment's own tex module. If it's there and I missed it just uncomment and re-add |
168 |
+# Tests pass without it |
169 |
+ |
170 |
+S="${WORKDIR}/${MY_P}" |
171 |
+ |
172 |
+PATCHES=( |
173 |
+ "${FILESDIR}"/${PV}-shell-injection-backport.patch |
174 |
+ "${FILESDIR}"/${PV}-shell-injection-backport2.patch |
175 |
+) |
176 |
+ |
177 |
+python_compile_all() { |
178 |
+ use doc && emake -C doc html |
179 |
+} |
180 |
+ |
181 |
+python_test() { |
182 |
+ cp -r -l tests "${BUILD_DIR}"/ || die |
183 |
+ # With pypy3 there is 1 error out of 1556 tests when run as is and |
184 |
+ # (SKIP=8, errors=1, failures=1) when run with 2to3; meh |
185 |
+ nosetests -w "${BUILD_DIR}"/tests || die "Tests fail with ${EPYTHON}" |
186 |
+} |
187 |
+ |
188 |
+python_install_all() { |
189 |
+ use doc && local HTML_DOCS=( doc/_build/html/. ) |
190 |
+ |
191 |
+ distutils-r1_python_install_all |
192 |
+ newbashcomp external/pygments.bashcomp pygmentize |
193 |
+} |