Skip to content

Commit a3b2827

Browse files
committed
Ensure we flatten compressor command too
1 parent 012b114 commit a3b2827

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

pipeline/compressors/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
import os
55
import posixpath
66
import re
7+
import subprocess
78

89
from itertools import takewhile
910

1011
from django.contrib.staticfiles.storage import staticfiles_storage
1112
from django.utils.encoding import smart_bytes, force_text
13+
from django.utils.six import string_types
1214

1315
from pipeline.conf import settings
14-
from pipeline.utils import to_class, relpath
1516
from pipeline.exceptions import CompressorError
17+
from pipeline.utils import to_class, relpath
1618

1719
URL_DETECTOR = r"""url\((['"]){0,1}\s*(.*?)["']{0,1}\)"""
1820
URL_REPLACER = r"""url\(__EMBED__(.+?)(\?\d+)?\)"""
@@ -234,8 +236,14 @@ def filter_js(self, js):
234236

235237
class SubProcessCompressor(CompressorBase):
236238
def execute_command(self, command, content):
237-
import subprocess
238-
pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
239+
argument_list = []
240+
for flattening_arg in command:
241+
if isinstance(flattening_arg, string_types):
242+
argument_list.append(flattening_arg)
243+
else:
244+
argument_list.extend(flattening_arg)
245+
246+
pipe = subprocess.Popen(argument_list, shell=True, stdout=subprocess.PIPE,
239247
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
240248
if content:
241249
content = smart_bytes(content)

tests/tests/test_compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from pipeline.collector import default_collector
99
from pipeline.compilers import Compiler, CompilerBase, SubProcessCompiler
10-
from pipeline.conf import settings
1110
from pipeline.exceptions import CompilerError
1211

1312
from tests.utils import _, pipeline_settings

tests/tests/test_compressor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ def test_url_rewrite_data_uri(self):
171171
""", output)
172172

173173
def test_compressor_subprocess_unicode(self):
174-
tests_path = os.path.dirname(os.path.dirname(__file__))
175-
output = SubProcessCompressor(False).execute_command(
176-
'/usr/bin/env cat',
177-
io.open(tests_path + '/assets/css/unicode.css', encoding="utf-8").read())
174+
path = os.path.dirname(os.path.dirname(__file__))
175+
content = io.open(path + '/assets/css/unicode.css', encoding="utf-8").read()
176+
output = SubProcessCompressor(False).execute_command(('cat',), content)
178177
self.assertEqual(""".some_class {
179178
// Some unicode
180179
content: "áéíóú";

tests/tests/test_storage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import unicode_literals
22

3-
from django.conf import settings
43
from django.contrib.staticfiles import finders
54
from django.contrib.staticfiles.storage import staticfiles_storage
65
from django.core.management import call_command

tests/tests/test_template.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.test import TestCase
88

99
from pipeline.jinja2 import PipelineExtension
10-
from pipeline.conf import settings
1110

1211
from tests.utils import pipeline_settings
1312

0 commit comments

Comments
 (0)