From aa1812c580ade33553258a32e7a1f6cc6a242c8d Mon Sep 17 00:00:00 2001 From: alde Date: Mon, 19 Apr 2021 12:08:42 -0400 Subject: [PATCH] encodeURI on all params in frontend api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/code-coverage/src/api.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/code-coverage/src/api.ts b/plugins/code-coverage/src/api.ts index f386fa03fe..1443f9de72 100644 --- a/plugins/code-coverage/src/api.ts +++ b/plugins/code-coverage/src/api.ts @@ -76,7 +76,7 @@ export class CodeCoverageRestApi implements CodeCoverageApi { async getCoverageForEntity( entityName: EntityName, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); return (await this.fetch( `/api/code-coverage/report?entity=${entity}`, )) as JsonCodeCoverage; @@ -86,9 +86,11 @@ export class CodeCoverageRestApi implements CodeCoverageApi { entityName: EntityName, filePath: string, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); return await this.fetch( - `/api/code-coverage/file-content?entity=${entity}&path=${filePath}`, + `/api/code-coverage/file-content?entity=${entity}&path=${encodeURI( + filePath, + )}`, ); } @@ -96,11 +98,11 @@ export class CodeCoverageRestApi implements CodeCoverageApi { entityName: EntityName, limit?: number, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); const hasValidLimit = limit && limit > 0; return (await this.fetch( `/api/code-coverage/history?entity=${entity}${ - hasValidLimit ? `&limit=${limit}` : '' + hasValidLimit ? `&limit=${encodeURI(`${limit}`)}` : '' }`, )) as JsonCoverageHistory; }