From fa6eb847b22cd76a428982ceb9937ad12dad9b6a Mon Sep 17 00:00:00 2001 From: Matthias Behr Date: Sat, 2 Jan 2021 11:12:56 +0100 Subject: [PATCH] fix(restquery): uri decode the parameters restQuery parameters will now be uri decoded first. E.g. /get/docs/0/filters?=&=... The param1 and param2 will be uri decoded first. Take care: extension fishbone >=1.3.1 supports this as well! With older versions all queries including % char will be broken. --- src/dltDocument.ts | 4 ++-- src/dltDocumentProvider.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/dltDocument.ts b/src/dltDocument.ts index 8d771eee..211f63f1 100644 --- a/src/dltDocument.ts +++ b/src/dltDocument.ts @@ -1785,11 +1785,11 @@ export class DltDocument { let didModifyAnyFilter = false; - const optionArr = options ? options.split('&') : []; // todo how to ensure that & is not part of it? need to percent encode.... need to uridecode/encode the options... + const optionArr = options ? options.split('&') : []; for (const commandStr of optionArr) { const eqIdx = commandStr.indexOf('='); const command = commandStr.slice(0, eqIdx); - const commandParams = commandStr.slice(eqIdx + 1); + const commandParams = decodeURIComponent(commandStr.slice(eqIdx + 1)); console.log(`restQueryDocsFilters: executing command = '${command}' with params='${commandParams}'`); switch (command) { diff --git a/src/dltDocumentProvider.ts b/src/dltDocumentProvider.ts index 6b13a31a..f61d49ec 100644 --- a/src/dltDocumentProvider.ts +++ b/src/dltDocumentProvider.ts @@ -784,7 +784,6 @@ export class DltDocumentProvider implements vscode.TreeDataProvider" const arrRes: Object[] = []; this._documents.forEach((doc) => { const resObj: { type: string, id: string, attributes?: Object } = @@ -889,7 +888,7 @@ export class DltDocumentProvider implements vscode.TreeDataProvider { console.log(`got opt=${opt}`); if (opt.startsWith('ecu=')) { - ecuNameFilter = opt.slice(opt.indexOf('=') + 1); + ecuNameFilter = decodeURIComponent(opt.slice(opt.indexOf('=') + 1)); // allow the string be placed in "": ecuNameFilter = ecuNameFilter.replace(/^"(.*?)"$/g, (match, p1, offset) => p1); if (ecuNameFilter.length === 0) { ecuNameFilter = undefined; } else {