Opened 9 years ago

Closed 9 years ago

#25283 closed Bug (fixed)

ManifestStaticFilesStorage does not works in edge cases while importing url font-face with IE hack

Reported by: Manuel Saelices Owned by: nobody
Component: contrib.staticfiles Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

See http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax

The collectstatic command fails when the CSS contains something like this:

@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/montserrat-ultralight-webfont.eot');
    src: url('../fonts/montserrat-ultralight-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/montserrat-ultralight-webfont.svg#../fonts/montserratultra_light') format('svg');
    font-weight: 100;
    font-style: normal;
}

The reason? The #../fonts/montserratultra_light part of the url declaration makes ManifestStaticFilesStorage fails to compute the relative path counting the .. and / ocurrences in the string. See this line: https://github.com/django/django/blob/4157c502a5202798d0f73645181cb82aa71d34d9/django/contrib/staticfiles/storage.py#L170

Change History (7)

comment:1 by Manuel Saelices, 9 years ago

Has patch: set

comment:3 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Tim Graham, 9 years ago

Easy pickings: unset
Patch needs improvement: set

I left some comments for improvement on the pull request. Please uncheck "Patch needs improvement" when you update it, thanks!

comment:5 by Jaap Roes, 9 years ago

I've updated the patch with an additional test in this PR https://github.com/django/django/pull/5642

I didn't add more comments as I have no idea what the rest of the code is doing, and it seems out of scope for this issue.

comment:6 by Jaap Roes, 9 years ago

Patch needs improvement: unset

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 7624fdb9:

Fixed #25283 -- Fixed collectstatic crash if a URL contains a fragment with a path.

A @font-face declaration may contain a fragment that looks like a relative path,
e.g. @font-face { src: url('../fonts/font.svg#../path/like/fragment'); }
In this case, an incorrect path was passed to the storage backend, which raised
an error that caused collectstatic to crash.

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