forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Change the way that uploaded images are shown; remove base64 strings (Gray Screen Fix) #8225
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
daniel-lxs
wants to merge
21
commits into
main
Choose a base branch
from
feat/webview-image-uri
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 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e71ec43
webview: never render base64; render backend-saved image URIs; allow …
daniel-lxs addd1bc
feat: enhance openImage function to handle vscode webview CDN URLs
daniel-lxs b10c874
feat: add clipboard copy functionality to openImage for file paths
daniel-lxs ab402bf
fix: improve vscode-cdn.net URL validation and add copy action check
daniel-lxs f34243e
Merge branch 'main' into feat/webview-image-uri
daniel-lxs e7531e5
fix: complete PR #8225 - add missing webview URI to base64 conversion
daniel-lxs 32b7085
optimize: implement efficient approach for PR #8225 - store base64 di…
daniel-lxs 7029f1d
security: fix polynomial regex and improve URL sanitization in imageD…
daniel-lxs a1c402e
security: harden URL parsing against ReDoS and injection attacks
daniel-lxs 3d796de
security: fix host injection vulnerability in URL validation
daniel-lxs 9dc853c
feat(images): persist base64 in backend messages; normalize URIs once…
daniel-lxs 634ee67
fix(image-uris): resolve review-bot issues
daniel-lxs 5d3f45b
fix(image-uris): broaden Unix path regex to include common Linux roots
daniel-lxs 1c7700e
feat(images): enforce 10MB limit UI+backend; reuse original base64 vi…
daniel-lxs 09d512b
chore(webview): add image utils for size estimation and 10MB limit en…
daniel-lxs c445cfe
fix(images): remove legacy file:// URI support and use centralized im…
daniel-lxs f3b31d7
test(images): add CDN URI conversion tests for normalizeImageRefsToDa…
daniel-lxs d56b74f
fix(tests): normalize expected path for CDN URI test in imageDataUrl.…
daniel-lxs 17ee88c
fix: optimize image handling with dual-storage approach
daniel-lxs 7ddfa4e
refactor: remove unnecessary caching from normalizeDataUrlsToFilePaths
daniel-lxs 3ff9b21
refactor: remove unused normalizeDataUrlsToFilePaths function
daniel-lxs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| vi.mock("vscode", () => { | ||
| const executeCommand = vi.fn() | ||
| const writeText = vi.fn() | ||
| const showInformationMessage = vi.fn() | ||
| const showErrorMessage = vi.fn() | ||
| const file = vi.fn((p: string) => ({ fsPath: p, path: p, scheme: "file" })) | ||
| const parse = (input: string) => { | ||
| if (input.startsWith("https://") && input.includes("vscode-cdn.net")) { | ||
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
|
||
| const url = new URL(input) | ||
| return { | ||
| scheme: "https", | ||
| authority: url.host, | ||
| path: url.pathname, | ||
| fsPath: url.pathname, | ||
| with: vi.fn(), | ||
| } | ||
| } | ||
| if (input.startsWith("file://")) { | ||
| return { | ||
| scheme: "file", | ||
| authority: "", | ||
| path: input.substring("file://".length), | ||
| fsPath: input.substring("file://".length), | ||
| with: vi.fn(), | ||
| } | ||
| } | ||
| return { | ||
| scheme: "file", | ||
| authority: "", | ||
| path: input, | ||
| fsPath: input, | ||
| with: vi.fn(), | ||
| } | ||
| } | ||
| return { | ||
| commands: { executeCommand }, | ||
| env: { clipboard: { writeText } }, | ||
| window: { showInformationMessage, showErrorMessage }, | ||
| Uri: { file, parse }, | ||
| } | ||
| }) | ||
|
|
||
| import * as vscode from "vscode" | ||
| import { openImage } from "../image-handler" | ||
|
|
||
| describe("openImage - vscode webview CDN url handling", () => { | ||
| const cdnUrlPosix = "https://file+.vscode-resource.vscode-cdn.net/file//Users/test/workspace/image.png" | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| test("opens image from vscode-cdn webview URL by stripping /file/ and normalizing", async () => { | ||
| await openImage(cdnUrlPosix) | ||
|
|
||
| // Should normalize to /Users/test/workspace/image.png and open it | ||
| expect((vscode.Uri.file as any).mock.calls.length).toBe(1) | ||
| const calledWithPath = (vscode.Uri.file as any).mock.calls[0][0] | ||
| expect(calledWithPath).toBe(require("path").normalize("/Users/test/workspace/image.png")) | ||
|
|
||
| expect(vscode.commands.executeCommand).toHaveBeenCalledTimes(1) | ||
| expect(vscode.commands.executeCommand).toHaveBeenCalledWith( | ||
| "vscode.open", | ||
| expect.objectContaining({ fsPath: calledWithPath }), | ||
| ) | ||
| expect(vscode.window.showErrorMessage).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| test("copy action writes normalized fs path to clipboard (no open)", async () => { | ||
| await openImage(cdnUrlPosix, { values: { action: "copy" } }) | ||
|
|
||
| const expectedPath = require("path").normalize("/Users/test/workspace/image.png") | ||
| expect(vscode.env.clipboard.writeText).toHaveBeenCalledWith(expectedPath) | ||
| expect(vscode.commands.executeCommand).not.toHaveBeenCalled() | ||
| }) | ||
| }) | ||
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.