Skip to content
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

fix: do not reject unknown schemes in WindowStateExt.asExternalUri #13057

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/plugin-ext/src/plugin/window-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { WindowState } from '@theia/plugin';
import { WindowStateExt, WindowMain, PLUGIN_RPC_CONTEXT } from '../common/plugin-api-rpc';
import { Event, Emitter } from '@theia/core/lib/common/event';
import { RPCProtocol } from '../common/rpc-protocol';
import { Schemes } from '../common/uri-components';

export class WindowStateExtImpl implements WindowStateExt {

Expand Down Expand Up @@ -50,16 +49,17 @@ export class WindowStateExtImpl implements WindowStateExt {
}

openUri(uri: URI): Promise<boolean> {
if (!uri.scheme.trim().length) {
throw new Error('Invalid scheme - cannot be empty');
}

return this.proxy.$openUri(uri);
}

async asExternalUri(target: URI): Promise<URI> {
if (!target.scheme.trim().length) {
throw new Error('Invalid scheme - cannot be empty');
}
if (Schemes.http !== target.scheme && Schemes.https !== target.scheme) {
AlexandraBuzila marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(`Invalid scheme '${target.scheme}'`);
}

const uri = await this.proxy.$asExternalUri(target);
return URI.revive(uri);
Expand Down
Loading