Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The two following bugs were fixed:
1. Dead Symlink Handling
Description
When serving the dir
/
and trying to navigate to other folders, i.e./etc/
, the request made was to/tc
.Problem
The function
get_relative_path
inutils/path.py
worked fine for every served directory because the functionos.path.abspath
, used multiple times within the code, removed any ending/
character. The problem came when the served directory was/
. This was the only case where a folder contained a finishing slash/
causing a bug in how the path was interpreted.Solution
Substitute the previous logic to get a relative path using now the
os.path.relpath()
function, and manually handling the edge case of/
being served with a specialif
statement to convert it to the empty string''
.2. Serving "/" leads to miss the first letter of directory
Description
Web server crashes if it's asked to list a directory containing a dead symlink.
Problem
The function
process_files
calls the functionfile.is_dir()
. When the variablefile
is a dead symlink, this raises an exception which is not handled and makes Updog crash.Solution
Add an extra check before the line
file.is_dir()
where we validate that the file exists, using theos.path.exists()
function.