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
…13057)

Fixes #128210

Contributed on behalf of STMicroelectronics

Signed-off-by: Alexandra Buzila <[email protected]>
  • Loading branch information
AlexandraBuzila authored Dec 14, 2023
1 parent de4c424 commit ee085d5
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 ee085d5

Please sign in to comment.