Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Bugs on Issues 6 and 11 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maurodelossantos
Copy link
Owner

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 in utils/path.py worked fine for every served directory because the function os.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 special if 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 function file.is_dir(). When the variable file 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 the os.path.exists() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant