Opened 12 years ago

Closed 12 years ago

#17806 closed Bug (fixed)

CachedFilesMixin url_converter doesn't handle absolute paths correctly

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

Description

This code works fine for an absolute url that is within one folder of static, ie: url(/static/foo/bar.png)

The bug I'm seeing happens with absolute paths and multiple subfolders: url(/static/foo/bar/yak.png)

All of the logic is within CachedFilesMixin -> url_converter -> converter

The result of the bug is: When you're using any staticfile storage that includes CachedFilesMixin, collecstatic fails (throws an exception) when it tries to update a css file that has an absolute reference to another asset that is in a subfolder.

I've created a small test application here:
https://github.com/lpetre/django-cachedstorage-bug

I've also added regressiontests and a potential fix to a fork of the django project on github. I'll update this ticket shortly with that url.

Attachments (2)

ticket17806_tests.diff (1.5 KB ) - added by lpetre 12 years ago.
This diff adds some regression tests that demonstrate the bug
ticket17806_fix.diff (637 bytes ) - added by lpetre 12 years ago.
This is a potential fix for this issue

Download all attachments as: .zip

Change History (4)

by lpetre, 12 years ago

Attachment: ticket17806_tests.diff added

This diff adds some regression tests that demonstrate the bug

by lpetre, 12 years ago

Attachment: ticket17806_fix.diff added

This is a potential fix for this issue

comment:1 by lpetre, 12 years ago

Has patch: set
Patch needs improvement: set
Type: UncategorizedBug

comment:2 by Jannis Leidel, 12 years ago

Resolution: fixed
Status: newclosed

In [17622]:

Fixed #17806 -- Fixed off-by-n error in the CachedStaticFilesStorage that prevented it from finding files in nested directories. Many thanks to lpetre.

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