Opened 5 years ago

Closed 5 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: jezdez 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 5 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by aaugustin

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 5 years ago by jezdez

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 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

In [17068]:

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

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