fix(webdav): avoid duplicate BasePath resolution - #9619
Open
014-code wants to merge 1 commit into
Open
Conversation
Collaborator
|
Nice catch, this one was genuinely broken. I traced it through: JoinPath always prepends BasePath via JoinBasePath, so the old branch ended up applying it twice (/cc -> /webdav/cc -> /webdav/webdav/cc). Stripping the prefix first and letting JoinPath add it back once is the right fix, and since IsSubPath is path-aware, something like /webdavfoo wont get mis-stripped against base /webdav. The tests hit exactly the cases I would have worried about. LGTM. |
okatu-loli
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix WebDAV path resolution for users configured with a non-root BasePath.
When a WebDAV user has a BasePath such as
/webdav, a request likeMKCOL /dav/cc-switch-sync/was incorrectly resolved to/webdav/webdav/cc-switch-sync.This caused the underlying storage lookup to fail with
409 Conflictbecause the expected parent directory did not exist.This change normalizes requests that already include the user's BasePath before calling
User.JoinPath, preventing duplicate BasePath concatenation.Related Issue
Closes #9613
Tests
Added
TestResolvePathcovering:Tests passed:
go test ./server/webdav ./pkg/utils ./internal/model -count=1Result:
ok github.com/alist-org/alist/v3/server/webdavok github.com/alist-org/alist/v3/pkg/utilsinternal/modelhas no test files