Fix relative send_from_directory for package apps #921

wants to merge 1 commit into


2 participants

uniphil commented Dec 3, 2013

The bug is basically: if a relative directory path is provided to send_from_directory, in a package application things get messed up, and it doesn't work at all:

I threw a longer explanation of the current issue in a gist, and made a simple repo showing the problem here.

My proposal is to expand the directory argument of send_from_directory(directory, filename, **options) to an absolute path using current_app.root_path if it is not absolute.

This change will affect the arguments passed to send_file for module apps, but it's just breaking out the absolute path earlier, so I don't think this should break anything that currently works? All the tests pass.

I also couldn't figure out where a test should go for this, or if a test should even be added. I couldn't find any tests for send_from_directory (there are some for send_file), and I also didn't know the best way for using a package app in a test. If you'd like tests added for this behavior I'd be happy to write them with a few pointers on how to approach it.

This comment has been minimized.

Show comment Hide comment

mitsuhiko Feb 9, 2014


Fixed this now and added a testcase.


mitsuhiko commented Feb 9, 2014

Fixed this now and added a testcase.

@mitsuhiko mitsuhiko closed this Feb 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment