-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(server): handle localized Windows provider probe output #1895
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
raulpesilva
wants to merge
8
commits into
pingdotgg:main
Choose a base branch
from
raulpesilva:feat/localized-windows-output
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3203a02
fix(server): handle localized Windows provider probe output
raulpesilva 21be66e
test(web): fix catalog lint warning
raulpesilva 6f24686
fix(server): decode UTF-16LE provider streams safely
raulpesilva fb0465e
fix(server): preserve unquoted Windows path backslashes
raulpesilva 19a503a
fix(server): avoid short UTF-16LE false positives
raulpesilva c66a714
refactor(server): remove redundant command output lowercase
raulpesilva 27a8248
fix(server): support Windows provider paths with spaces
raulpesilva 1e1a9e7
Merge branch 'main' into feat/localized-windows-output
raulpesilva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { Effect, Stream } from "effect"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { | ||
| collectStreamAsString, | ||
| makeProviderCommand, | ||
| quoteWindowsShellArgument, | ||
| } from "./providerSnapshot"; | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllGlobals(); | ||
| }); | ||
|
|
||
| describe("collectStreamAsString", () => { | ||
| it("decodes UTF-16LE Windows output across odd chunk boundaries", async () => { | ||
| vi.stubGlobal("process", { ...process, platform: "win32" }); | ||
|
|
||
| const output = Buffer.from("n\u00e3o \u00e9 reconhecido", "utf16le"); | ||
| const firstChunk = new Uint8Array(output.subarray(0, 5)); | ||
| const secondChunk = new Uint8Array(output.subarray(5)); | ||
|
|
||
| const result = await Effect.runPromise( | ||
| collectStreamAsString(Stream.make(firstChunk, secondChunk)), | ||
| ); | ||
|
|
||
| expect(result).toBe("n\u00e3o \u00e9 reconhecido"); | ||
| }); | ||
|
|
||
| it("does not misclassify short UTF-8 Windows output as UTF-16LE", async () => { | ||
| vi.stubGlobal("process", { ...process, platform: "win32" }); | ||
|
|
||
| const result = await Effect.runPromise( | ||
| collectStreamAsString(Stream.make(new Uint8Array(Buffer.from("AB", "utf8")))), | ||
| ); | ||
|
|
||
| expect(result).toBe("AB"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("quoteWindowsShellArgument", () => { | ||
| it("preserves trailing backslashes when quoting is not needed", () => { | ||
| expect(quoteWindowsShellArgument("C:\\tools\\")).toBe("C:\\tools\\"); | ||
| }); | ||
|
|
||
| it("doubles trailing backslashes only when quoting is needed", () => { | ||
| expect(quoteWindowsShellArgument("C:\\Program Files\\tool\\")).toBe( | ||
| '"C:\\Program Files\\tool\\\\"', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("makeProviderCommand", () => { | ||
| it("uses a shell command string for Windows paths with spaces", () => { | ||
| vi.stubGlobal("process", { ...process, platform: "win32" }); | ||
|
|
||
| const command = makeProviderCommand("C:\\Program Files\\Codex\\codex.exe", ["--version"]); | ||
| const resolved = command as unknown as { | ||
| command: string; | ||
| args: ReadonlyArray<string>; | ||
| options: { shell?: boolean }; | ||
| }; | ||
|
|
||
| expect(resolved.command).toBe('"C:\\Program Files\\Codex\\codex.exe" --version'); | ||
| expect(resolved.args).toEqual([]); | ||
| expect(resolved.options.shell).toBe(true); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.