Skip to content

Fix --no-symlinks not filtering files and dirs nested in symlinks#1495

Merged
svenstaro merged 1 commit intosvenstaro:masterfrom
ahti:symlink-nested-dir
Jun 24, 2025
Merged

Fix --no-symlinks not filtering files and dirs nested in symlinks#1495
svenstaro merged 1 commit intosvenstaro:masterfrom
ahti:symlink-nested-dir

Conversation

@ahti
Copy link
Copy Markdown
Contributor

@ahti ahti commented May 2, 2025

Currently, if you can guess the name of a symlinked dir, and the name of files or directories nested inside, miniserve will not prevent you from accessing them, even when --no-symlinks is passed.

Copy link
Copy Markdown
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a few nits.

Comment on lines +388 to +404
if !no_symlinks {
return true;
}

let mut full_path = base_path.clone();

for component in path.components() {
full_path.push(component);
if full_path.is_symlink() {
return false;
}
}

true
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is now complex enough that I'd like a few comments sprinkled in here.

@ahti ahti force-pushed the symlink-nested-dir branch from 673fb62 to 593091e Compare June 18, 2025 23:52
@svenstaro svenstaro merged commit 563e239 into svenstaro:master Jun 24, 2025
17 checks passed
svenstaro added a commit that referenced this pull request Jun 24, 2025
@ahti ahti deleted the symlink-nested-dir branch February 8, 2026 05:08
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.

2 participants