aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'wkhtmltopdf/utils.py')
-rw-r--r--wkhtmltopdf/utils.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py
index 3c9b4a7..053a2e7 100644
--- a/wkhtmltopdf/utils.py
+++ b/wkhtmltopdf/utils.py
@@ -5,6 +5,7 @@ from itertools import chain
import os
import re
import sys
+import shlex
try:
from urllib.request import pathname2url
@@ -88,13 +89,19 @@ def wkhtmltopdf(pages, output=None, **kwargs):
cmd = 'WKHTMLTOPDF_CMD'
cmd = getattr(settings, cmd, os.environ.get(cmd, 'wkhtmltopdf'))
- ck_args = list(chain(cmd.split(),
+ ck_args = list(chain(shlex.split(cmd),
_options_to_args(**options),
list(pages),
[output]))
ck_kwargs = {'env': env}
- if hasattr(sys.stderr, 'fileno'):
+ # Handling of fileno() attr. based on https://github.com/GrahamDumpleton/mod_wsgi/issues/85
+ try:
+ i = sys.stderr.fileno()
ck_kwargs['stderr'] = sys.stderr
+ except (AttributeError, IOError):
+ # can't call fileno() on mod_wsgi stderr object
+ pass
+
return check_output(ck_args, **ck_kwargs)
@@ -152,7 +159,7 @@ def make_absolute_paths(content):
has_scheme = re.compile(r'^[^:/]+://')
for x in overrides:
- if has_scheme.match(x['url']):
+ if not x['url'] or has_scheme.match(x['url']):
continue
if not x['root'].endswith('/'):