{{ message }}
Percent-decode URL paths before filesystem use in any::connect()#7080
Open
adlk wants to merge 2 commits intosurrealdb:mainfrom
Open
Percent-decode URL paths before filesystem use in any::connect()#7080adlk wants to merge 2 commits intosurrealdb:mainfrom
adlk wants to merge 2 commits intosurrealdb:mainfrom
Conversation
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.

What is the motivation?
any::connect()passes percent-encoded paths straight to the filesystem without decoding them. For example, connecting withsurrealkv:///tmp/surrealdb%20path%20test/dbcreates a directory literally namedsurrealdb%20path%20testinstead ofsurrealdb path test. This makes it impossible to use paths with spaces (or other special characters) through theany::connect()API, even though the typed engine API (Surreal::new::<SurrealKv>()) handles them correctly.The same issue exists in
surrealdb-core'sDatastore::new(), which affects the Node.js embedded engine (@surrealdb/node) — the path extracted after splitting the scheme is never percent-decoded before being passed to the storage engine.What does this change do?
Two targeted fixes that cover both the Rust SDK and the core datastore paths:
surrealdbSDK crate (surrealdb/src/opt/endpoint/mod.rs): Addedpercent_decode_str()inpath_to_string()so URL-encoded characters are decoded before the path is used on the filesystem. This is the single function all local engine endpoints (SurrealKV, RocksDB, mem with persistence) pass through, so the fix covers all of them.surrealdb-corecrate (surrealdb/core/src/kvs/ds.rs): Addedpercent_decode_str()inCommunityComposer::new_transaction_builder()right after the scheme/path split. This fixes the same bug for consumers that callDatastore::new()directly (e.g. the Node.js embedded engine).Supporting changes:
percent-encodingas a workspace dependency (already in the dep tree viaurl)percent-encodingto bothsurrealdbandsurrealdb-corecrate dependenciesWhat is your testing strategy?
test_path_to_string_percent_decodinginsurrealdb/src/opt/endpoint/mod.rsthat verifies%20decodes to spaces,%23decodes to#, and plain paths pass through unchanged. All existing and new tests pass viacargo test -p surrealdb --lib opt::endpoint::tests.%20) correctly create directories with literal spaces.@surrealdb/nodenative addon against this branch and confirmed it resolves the issue for the Node.js embedded engine as well.Is this related to any issues?
Fixes #6911
Does this change need documentation?
Does this change make any alterations to environment variables or CLI commands?
Have you read the Contributing Guidelines?