Skip to content

collectstatic crashes if static file URL contains question mark on Windows #690

@Teraskull

Description

@Teraskull

Python Version

3.14.3

Django Version

6.0.2

Package Version

6.12.0

Description

Hi,

When trying to collect static files to /staticfiles/ with WHITENOISE_KEEP_ONLY_HASHED_FILES = True, the collectstatic command fails with the following error on Windows:

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Users\\user\\Desktop\\project\\staticfiles\\rest_framework\\fonts\\fontawesome-webfont.dcb26c7239d8.ttf?v=4.0.3'

Example location of error in fontawesome-webfont.ttf:

@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=4.0.3');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

Strangely, there is no error when setting WHITENOISE_KEEP_ONLY_HASHED_FILES = False.

As seen in the error, static file URLs are getting parsed in the Django REST Framework library, but if they contain some cache-buster like ?v=4.0.3, collecting fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions