Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sanitize JoinPath handling#19923

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
feichai0017 wants to merge12 commits intoduckdb:main
base:main
Choose a base branch
Loading
fromfeichai0017:sanitize-joinpath

Conversation

@feichai0017
Copy link
Contributor

ImproveFileSystem::JoinPath to normalize separators and dot segments, respect absolute RHS, preserve URI schemes, and handle drive prefixes.
Added file system tests covering separator normalization, .. folding, absolute override, and repeated separator cleanup.

@feichai0017feichai0017 changed the titleAdd thread-local logger supportSanitize JoinPath handlingNov 25, 2025
@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 25, 2025 06:11
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 25, 2025 06:11
@pdetpdet requested a review fromMaxxenNovember 25, 2025 12:20
@Mytherin
Copy link
Collaborator

Thanks for the PR!

Is there a particular issue that this is solving - or is this just picking up a random FIXME in the code? I'm not opposed to the changes but if there is an underlying bug this is addressing adding tests for those would be good.

We might also want to expose this method in the SQL layer incore_functions, e.g.path_join('...', '...', '...') similar toos.path.join in Python. This might be useful when constructing paths. That would also make testing this method easier.

@feichai0017
Copy link
ContributorAuthor

This isn’t random cleanup. JoinPath is used for temp files, logs, and test paths. Today it just glues strings, so an absolute RHS givesdir//abs/path and duplicate separators/.//../ leak through (the new test shows it). The change normalizes and lets an absolute RHS win. If you want SQL access too, I can add apath_join(...) builtin in a follow-up.

@Mytherin
Copy link
Collaborator

Thanks for the clarification - adding the SQL function in a follow-up makes sense to me.
Could you just add some more tests then, there are a number of edge cases mentioned in the code that appear to be untested, e.g. some tests I could think of:

  • JoinPath("dir/subdir/..", "sibling")
  • JoinPath("./dir/./subdir/./..", "./sibling/.")
  • JoinPath("dir/..", "../..")
  • JoinPath("/usr/local", "../..") (this should return "/" I think?)
  • JoinPath("/", "usr/local") (follow-up from the previous one)
  • JoinPath("/usr/local", "../../..") (not sure what this should return)
  • JoinPath("file:/usr/local", "../bin")
  • JoinPath("file:/usr/local", "../bin")
  • JoinPath("C:\", "..")
  • JoinPath("C:\", "..\..")
  • JoinPath("C:", "system32")
  • JoinPath("C:\", "system32")
  • JoinPath("C:drive_relative_path", "path")
  • JoinPath("C:drive_relative_path", "..\path") (I think this needs to beC:path,notC:\path, otherwise the relative property is lost)

Maybe we could also add some special tests for Windows specifically, i.e. when the separator is\.

@feichai0017
Copy link
ContributorAuthor

Sure! I will add more edge test cases

@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 28, 2025 13:22
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 28, 2025 14:31
@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 28, 2025 23:27
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 28, 2025 23:27
@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 28, 2025 23:30
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 28, 2025 23:30
@feichai0017feichai0017 marked this pull request as draftNovember 29, 2025 01:33
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 29, 2025 01:33
@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 29, 2025 09:38
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 29, 2025 09:39
@duckdb-draftbotduckdb-draftbot marked this pull request as draftNovember 29, 2025 09:47
@feichai0017feichai0017 marked this pull request as ready for reviewNovember 29, 2025 09:47
@feichai0017
Copy link
ContributorAuthor

feichai0017 commentedNov 29, 2025
edited
Loading

  • Design: Added a variadic scalar functionpath_join(path, ...) that uses the currentFileSystem::JoinPath to stitch components, inheriting separator normalization, ./.. folding, absolute RHS override, and URI preservation; returns NULL if any argument is NULL. Registered in the built-in list with VARARGS VARCHAR.
  • Tests: Added sqllogictesttest/sql/function/string/path_join.test covering duplicate separator cleanup, parent folding, absolute override, root joins, cross-platform separator replacement, and URI preservation.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@MaxxenMaxxenAwaiting requested review from Maxxen

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@feichai0017@Mytherin@pdet

[8]ページ先頭

©2009-2025 Movatter.jp