Repository navigation
chore: add rust-toolchain.toml - #46
Merged
Merged
Conversation
Boshen
force-pushed
the
rust-toolchain.toml
branch
from
November 29, 2024 05:15
aa8ec77 to
ef36bbe
Compare
Brooooooklyn
added a commit
that referenced
this pull request
Sep 14, 2026
Take idna for exact Node parity on Unicode authorities: fullwidth and compatibility characters fold to their ASCII forms (localhost is localhost, ℡ is tel) and valid xn-- labels decode, while invalid hosts stay literal the way Node is lenient about them. The dependency is Windows-only in production builds and a dev-dependency so the module's tests link everywhere; the hand-rolled punycode decoder is gone.
Brooooooklyn
added a commit
that referenced
this pull request
Sep 14, 2026
…e drives The parser canonicalizes the authority before anything else: fullwidth 127.1 is IPv4 127.0.0.1 and 256.1 is rejected. The forbidden-character check now also runs on the mapped host, so % mapping to % is rejected. A leading C| drive folds even without dot segments, while a pipe in a later segment stays literal.
Brooooooklyn
added a commit
that referenced
this pull request
Sep 14, 2026
The lenient fallback kept every mapping failure, so a zero-width joiner or a lone soft hyphen (mapping to an empty host) produced a UNC path Node rejects. Only undecodable xn-- labels keep their literal spelling, matching Node; everything else failing to map is rejected.
Brooooooklyn
added a commit
that referenced
this pull request
Sep 14, 2026
Whole-host fallback let any xn-- label keep an unrelated invalid label literal, and label[..4] panicked when byte four split a UTF-8 character. UTS #46 now runs per label: undecodable xn-- labels keep their spelling, other failures reject the host, and the prefix check is byte-based.
Brooooooklyn
added a commit
that referenced
this pull request
Sep 14, 2026
## Summary Fixes #744. Windows UNC paths (`\\server\share\…`) round trip through `file:` URLs with the server name in the authority (`file://server/share/…`, the form `pathToFileURL` produces), instead of failing resolution or generating `file://///server/…`. - **`file_url_to_path` (Windows)**: `file://server/share/…` maps its authority back to a leading `\\server\…`, with percent-decoding applied to both the host and the path; `file://localhost/…` maps to no authority, matching `fileURLToPath`; the `file:///C:/…` drive form is unchanged. - **`path_to_file_url` (Windows)**: a `\\` or `//` prefix makes the first component the UNC authority — percent-encoded — and everything else keeps the `file:///C:/…` form, matching `pathToFileURL`. - **`create_resolve`** now treats every `file://` specifier as an absolute path, UNC form included. - **Pathname encoding**: the UNC path is percent-encoded the way the `file:` URL path setter encodes it (`/` separators stay, everything outside the unreserved set becomes `%XX`), with query/fragment appended verbatim — a literal `%` in a file name can no longer be read back as an escape, and `#` can no longer start a fragment. Found by an adversarial review of this branch. (The same pre-existing gap for drive-letter paths is left untouched here, as it predates this change and is not part of #744.) - **IDNA hosts**: `pathToFileURL` writes a non-ASCII server name as an `xn--` punycode authority and `fileURLToPath` maps it back through IDNA to-Unicode, so incoming URLs now punycode-decode `xn--` labels (RFC 3492, decode-only, no new dependency). A `#` in a file name is safe: oxc_resolver's fragment-as-path fallback resolves the full path before treating it as a fragment (pinned by a `hash#name.ts` fixture). - The Windows rules live in a `#[cfg(any(windows, test))]` module: production builds on other platforms compile none of the UNC code, while `cargo test` exercises the full matrix on every platform. Also adds the missing `rlib` crate type so `cargo test` can link unit tests at all. - Adds a `cargo test` step to the CI lint job (previously only clippy ran). ## Tests - **13 Rust unit tests** covering the drive and UNC forms in both directions, percent-decoding of host and path, percent-encoding of URL-significant characters (`%`, `#`, space, non-ASCII) with a full round trip, the `localhost` authority, malformed escapes copied verbatim, invalid UTF-8 rejected, and non-`file:` URLs rejected. - **`packages/integrate-vitest/__tests__/unc-paths.spec.ts`**: a drive-letter fixture cannot catch this bug (`file:///C:/…` matches the old prefix both ways), so the spec stands up a real share on the runner itself (`net share`, reached as `\\%COMPUTERNAME%\OXCNODEUNC`) and runs a TypeScript module through a UNC `file:` URL, a relative import from a UNC parent, a UNC CLI entry point, and a file whose name contains a literal `%`. The fixture's `tsconfig.json` asks for `useDefineForClassFields: false`, so the expected setter output also proves tsconfig discovery works through UNC paths. The spec self-skips when the share cannot be created (no admin rights, Server service stopped). Verified locally: `cargo test` (11 passed), `cargo clippy --all-targets --all-features -- -D warnings` clean, `cargo fmt --check` clean, `pnpm lint` clean, and the full `pnpm test` integration suite (74 passed, UNC spec skipped on macOS as designed). Closes #744 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Windows ESM resolve/load URL↔path conversion on a security-sensitive boundary; scope is Windows-only with extensive Rust and integration tests, but regressions would affect UNC and unusual file URL spellings. > > **Overview** > Fixes **Windows UNC** handling so `\\server\share\…` matches Node’s `pathToFileURL` / `fileURLToPath` form (`file://server/share/…`) instead of mis-parsing the authority or emitting broken URLs like `file://///server/…`. > > A new **`windows_file_url`** module (Windows production + cross-platform unit tests) implements bidirectional conversion with percent-encoding, IDNA host handling, localhost drive paths, and URL-parser edge cases. **`create_resolve`** now treats any case-insensitive `file://` specifier as absolute (including UNC), strips tab/newline only for file-URL classification on Windows, escapes `#` in paths for the resolver while preserving query/fragment as module identity, and builds resolved URLs via **`path_to_file_url`** on Windows. > > Build/test plumbing adds **`rlib`** so `cargo test` can link the crate, pulls **`idna`** for UTS #46 host canonicalization, runs **`cargo test --all-features`** in CI, and adds Vitest specs that use a loopback **`net share`** when admin rights allow (otherwise skipped). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4c31f97. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.
No description provided.