Opened 7 years ago

Closed 7 years ago

#16966 closed Bug (fixed)

CachedStaticFilesStorage chokes on file references that end with a '#' or '?' character

Reported by: mkai Owned by: nobody
Component: contrib.staticfiles Version: master
Severity: Normal Keywords: CachedStaticFilesStorage, CachedFilesMixin, collectstatic
Cc: Jannis Leidel Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm using the "bullet proof" font-face syntax as described here:

It uses two special file references:

-- for IE support

url('myfont-webfont.svg#svgFontName') format('svg') -- for SVG fonts

During post_process, CachedStaticFilesStorage tries to open these files from disk, including the '?' and/ or '#' characters, which of course fails, and the processing stops.

The desired behavior would be that when trying to open the file from disk during collectstatic, the remainder following a question mark or hash character is stripped ("myfont-webfont.eot"), but that it still gets included into the hashed file ("myfont-webfont.<MD5>.eot?#iefix").

Change History (4)

comment:1 Changed 7 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Aymeric Augustin

If I remember correctly, a unique id is added as query string in references to external files, and this feature should be kept.

However, the fragment can be preserved.

comment:3 Changed 7 years ago by Jannis Leidel

Actually the unique ID is added to the filename not the querystring.

But other than that you're right, we need to strip the querystring and fragement when trying to access the file but add it later again when rewriting the url() with the filename that includes the hash.

comment:4 Changed 7 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [17068]:

Fixed #16966 -- Stopped CachedStaticFilesStorage from choking on querystrings and path fragments.

Note: See TracTickets for help on using tickets.
Back to Top