Skip to content

Commit

Permalink
fix: do not reject unknown schemes in WindowStateExt.asExternalUri
Browse files Browse the repository at this point in the history
Fixes #128210

Contributed on behalf of STMicroelectronics

Signed-off-by: Alexandra Buzila <[email protected]>
  • Loading branch information
AlexandraBuzila committed Dec 12, 2023
1 parent 273c7e2 commit d7dbfe4
Showing 1 changed file with 4 additions and 4 deletions.
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) {
throw new Error(`Invalid scheme '${target.scheme}'`);
}

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

0 comments on commit d7dbfe4

Please sign in to comment.