Commit 073fbd73 by Timothée Peignier

Fix url rewriting. Close #388

parent 5d0ecfa6
......@@ -14,8 +14,8 @@ from pipeline.storage import default_storage
from pipeline.utils import to_class, relpath
from pipeline.exceptions import CompressorError
URL_DETECTOR = r'url\([\'"]?([^\s)]+\.[a-z]+[^\'"\s]*)[\'"]?\)'
URL_REPLACER = r'url\(__EMBED__(.+?)(\?\d+)?\)'
URL_DETECTOR = r"""url\(['"]{0,1}\s*(.*?)["']{0,1}\)"""
URL_REPLACER = r"""url\(__EMBED__(.+?)(\?\d+)?\)"""
NON_REWRITABLE_URL = re.compile(r'^(http:|https:|data:|//)')
DEFAULT_TEMPLATE_FUNC = "template"
......@@ -158,7 +158,7 @@ class Compressor(object):
return False
if not (re.search(settings.PIPELINE_EMBED_PATH, path.replace('\\', '/')) and self.storage.exists(path)):
return False
if not ext in EMBED_EXTS:
if ext not in EMBED_EXTS:
return False
if not (font or len(self.encoded_content(path)) < settings.PIPELINE_EMBED_MAX_IMAGE_SIZE):
return False
......
......@@ -21,3 +21,4 @@
.no-protocol-url {
background-image: url(//images/sprite-buttons.png);
}
@font-face{src:url(../fonts/pipeline.eot);src:url(../fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../fonts/pipeline.woff) format('woff'),url(../fonts/pipeline.ttf) format('truetype');}
......@@ -150,6 +150,7 @@ class CompressorTest(TestCase):
.no-protocol-url {
background-image: url(//images/sprite-buttons.png);
}
@font-face{src:url(../pipeline/fonts/pipeline.eot);src:url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../pipeline/fonts/pipeline.woff) format('woff'),url(../pipeline/fonts/pipeline.ttf) format('truetype');}
""", output)
def test_url_rewrite_data_uri(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment