Repository navigation
fix(tui,coding-agent): survive lone surrogates in table cells and terminate the WebP EXIF scan #2033
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
Closed
Closed
fix(tui,coding-agent): survive lone surrogates in table cells and terminate the WebP EXIF scan #2033
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4410455
fix(tui,coding-agent): survive lone surrogates in table cells and ter…
snimu 45cad18
test(tui): run the selection-metadata pin under the package's node --…
snimu b1c00af
Merge remote-tracking branch 'origin/main' into fix/tui-media-defects
snimu a3d1139
refactor(tui): compress the surrogate-sanitizing comment
snimu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - The WebP EXIF chunk scan reads chunk sizes as unsigned, so a crafted or corrupt image can no longer hang the process in an infinite scan loop. |
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,18 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { applyExifOrientation } from "../src/utils/exif-orientation.js"; | ||
| import type { PhotonImageType } from "../src/utils/photon.js"; | ||
|
|
||
| type Photon = typeof import("@silvia-odwyer/photon-node"); | ||
|
|
||
| describe("exif orientation", () => { | ||
| it("terminates the WebP chunk scan when a chunk size has the high bit set", () => { | ||
| const bytes = new Uint8Array(20); | ||
| bytes.set([0x52, 0x49, 0x46, 0x46], 0); // RIFF | ||
| bytes.set([0x57, 0x45, 0x42, 0x50], 8); // WEBP | ||
| bytes.set([0x4a, 0x55, 0x4e, 0x4b], 12); // JUNK | ||
| bytes.set([0xf8, 0xff, 0xff, 0xff], 16); // chunk size 0xFFFFFFF8: read signed (-8), the scan re-visits this chunk forever | ||
| // Orientation resolves to 1, so neither photon nor the image is ever touched. | ||
| const image = {} as PhotonImageType; | ||
| expect(applyExifOrientation({} as Photon, image, bytes)).toBe(image); | ||
| }); | ||
| }); |
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 @@ | ||
| - Table cell selection markers no longer crash the renderer when cell content contains a lone UTF-16 surrogate; the surrogate is replaced before encoding. |
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,16 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| extractTableCellSelectionRegions, | ||
| markTableCell, | ||
| markTableEnd, | ||
| markTableStart, | ||
| } from "../src/selection-metadata.js"; | ||
|
|
||
| describe("selection metadata", () => { | ||
| it("marks cells containing lone surrogates without throwing", () => { | ||
| // The lone surrogate is replaced with U+FFFD, not crashed on. | ||
| const line = markTableEnd(markTableStart("") + markTableCell("cell text", 0, 0, 0, "broken \uD800 surrogate")); | ||
| const { regions } = extractTableCellSelectionRegions([line], () => ({})); | ||
| expect(regions[0]?.content).toBe("broken \uFFFD surrogate"); | ||
| }); | ||
| }); | ||
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
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.