Code

Opened 2 years ago

Closed 2 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: master
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 2 years ago.
This diff adds some regression tests that demonstrate the bug
ticket17806_fix.diff (637 bytes) - added by lpetre 2 years ago.
This is a potential fix for this issue

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by lpetre

This diff adds some regression tests that demonstrate the bug

Changed 2 years ago by lpetre

This is a potential fix for this issue

comment:1 Changed 2 years ago by lpetre

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Type changed from Uncategorized to Bug

comment:2 Changed 2 years ago by jezdez

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

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.