Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31000 closed Bug (duplicate)

Match @import rule and url() statement exclude of the css comment during the collectstatic.

Reported by: Tomáš Zigo Owned by: nobody
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords: staticfiles, collectstatic
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tomáš Zigo)

I use some extrenal js lib assets in the my django project (automatically installed by the bower js package manager).

Some css source code has url() statement inside the comment /* */ with wrong relatative path to img/font.

During running command python manage.py collectstatic I get error message.

Traceback (most recent call last):
  File "manage.py", line 26, in <module>
    execute_from_command_line(sys.argv)
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
    collected = self.collect()
  File "/home/test/.local/share/virtualenvs/klub-v-nnivlwsY/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 134, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'colorPicker/_blank.gif' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7fe6c456c8d0>.

The CSS file 'colorPicker/index.css' references a file which could not be found:
  colorPicker/_blank.gif

Please check the URL references in this CSS file, particularly any
relative paths which might be pointing to the wrong location.

url('_blank.gif') statement is inside comment in the css source code.

Problem is that @import rule and url() statement are checked in all css file source code content, include code between css comment /* */.
( regex pattern for the match rule/statement django.contrib.staticfiles.storage.HashedFilesMixin.patterns)

I write patch which match this rule and statement only outside of the css comment in css file source code.

PR

Change History (3)

comment:1 by Tomáš Zigo, 5 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: newclosed
Type: UncategorizedBug
Version: 2.2master

Duplicate of #21080.

comment:3 by Mariusz Felisiak, 5 years ago

Summary: Match @import rule and url() statement exclude of the css comment /* */ in the css file source code, during the run collectstatic commandMatch @import rule and url() statement exclude of the css comment during the collectstatic.
Note: See TracTickets for help on using tickets.
Back to Top