Skip to content

fix(webdav): avoid duplicate BasePath resolution - #9619

Open
014-code wants to merge 1 commit into
AlistGo:mainfrom
014-code:fix/webdav-resolve-path-basepath
Open

fix(webdav): avoid duplicate BasePath resolution#9619
014-code wants to merge 1 commit into
AlistGo:mainfrom
014-code:fix/webdav-resolve-path-basepath

Conversation

@014-code

Copy link
Copy Markdown

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 like MKCOL /dav/cc-switch-sync/ was incorrectly resolved to /webdav/webdav/cc-switch-sync.

This caused the underlying storage lookup to fail with 409 Conflict because 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 TestResolvePath covering:

  • Root requests with a non-root BasePath
  • Relative child paths with a non-root BasePath
  • Requests that already include the BasePath
  • Requests targeting the BasePath itself
  • Root BasePath behavior

Tests passed:

go test ./server/webdav ./pkg/utils ./internal/model -count=1

Result:

  • ok github.com/alist-org/alist/v3/server/webdav
  • ok github.com/alist-org/alist/v3/pkg/utils
  • internal/model has no test files

@okatu-loli

Copy link
Copy Markdown
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.

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.

[BUG] WebDAV 模块 ResolvePath 导致非根 BasePath 下路径双重拼接,引发 MKCOL 409 Conflict

2 participants