Attachment 'patch_htmldoc_escaping.patch'
Download 1 --- /root/CreatePdfDocument2_4_2.py 2010-09-18 18:23:23.000000000 +0200
2 +++ CreatePdfDocument.py 2014-08-18 03:50:11.370056029 +0200
3 @@ -212,6 +212,7 @@
4 import re
5 import copy
6 import shutil
7 +import subprocess
8 import StringIO
9 import array
10
11 @@ -496,30 +497,9 @@
12 return editorname
13
14
15 -def pipeCommand(cmdstr, input=None):
16 - child_stdin, child_stdout, child_stderr = os.popen3(cmdstr, u'b')
17 - try:
18 - if input:
19 - child_stdin.write(input)
20 - child_stdin.close()
21 - except:
22 - pass
23 -
24 - child_output = child_stdout.read()
25 - child_stdout.close()
26 -
27 - child_error = child_stderr.read()
28 - child_stderr.close()
29 -
30 - if os.name in ['posix', 'mac']:
31 - try:
32 - # REMARK: Otherwise we get <defunct> processes.
33 - os.wait()
34 - except OSError, e:
35 - # 10: No child processes.
36 - if e.errno != 10:
37 - raise
38 - return (child_output, child_error)
39 +def pipeCommand(tokens, input_data=None):
40 + proc = subprocess.Popen(tokens, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
41 + return proc.communicate(input_data)
42
43
44 class CreatePdfDocument(ActionBase):
45 @@ -1850,8 +1830,8 @@
46 if self.debug:
47 self.wrapper_emit_http_headers()
48 errmsg = self._(u'HTMLDOC command:') + u'<pre>' + wikiutil.escape(cmdstr) + u'</pre>'
49 - cmdstr = self.default_values['htmldoc_cmd'] + u' --help'
50 - (htmldoc_help, htmldoc_err) = pipeCommand(cmdstr)
51 + htmldocopts = [self.default_values['htmldoc_cmd'], u'--help']
52 + (htmldoc_help, htmldoc_err) = pipeCommand(htmldocopts)
53 errmsg += u'<p>Execute <tt>%s</tt><br /><pre>%s</pre></p>' % (wikiutil.escape(cmdstr), wikiutil.escape(htmldoc_help),)
54 if 'env' in self.request.__dict__:
55 reqenv = u'%s' % wikiutil.escape(self.request.env)
56 @@ -1859,7 +1839,7 @@
57 reqenv = u'None'
58 errmsg += u'<p>Python release %s<br />MoinMoin release <tt>%s</tt><br />CreatePdfDocument release <tt>%s</tt><br />self.request = <tt>%s</tt><br />self.request.env = <tt>%s</tt><br />os.environ = <tt>%s</tt></p>' % (wikiutil.escape(sys.version), wikiutil.escape(moinmoin_release), wikiutil.escape(__version__), wikiutil.escape(type(self.request)), wikiutil.escape(reqenv), wikiutil.escape(u"%s" % os.environ),)
59 else:
60 - (pdf, htmldoc_err) = pipeCommand(cmdstr, html)
61 + (pdf, htmldoc_err) = pipeCommand(htmldocopts, html)
62
63 # Check for error message on STDOUT.
64 if pdf[:8] == u'HTMLDOC ':
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.