Skip to content

Commit

Permalink
fix(restquery): uri decode the parameters
Browse files Browse the repository at this point in the history
restQuery parameters will now be uri decoded first.
E.g. /get/docs/0/filters?<cmd1>=<param1>&<cmd2>=<param2>...
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.
  • Loading branch information
mbehr1 committed Jan 2, 2021
1 parent 524649d commit fa6eb84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/dltDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/dltDocumentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ export class DltDocumentProvider implements vscode.TreeDataProvider<TreeViewNode
{
if (paths.length === 1) {
// get info about available documents:
// todo support options filter "ecu=<ecuname>"
const arrRes: Object[] = [];
this._documents.forEach((doc) => {
const resObj: { type: string, id: string, attributes?: Object } =
Expand Down Expand Up @@ -889,7 +888,7 @@ export class DltDocumentProvider implements vscode.TreeDataProvider<TreeViewNode
optionArr.forEach((opt) => {
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 {
Expand Down

0 comments on commit fa6eb84

Please sign in to comment.