Skip to content

Commit e7c63bc

Browse files
drosenbauerlispercat
authored andcommitted
Fix for issue #74: properties file reader does not handle escape characters
1 parent 07418db commit e7c63bc

4 files changed

Lines changed: 46 additions & 42 deletions

File tree

client/src/iiq-commands.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
33
import {Headers} from 'node-fetch';
44
import * as base64 from 'base-64';
55
import * as fs from 'fs';
6-
import * as propertiesReader from 'properties-reader';
6+
import {getProperties} from 'properties-file';
77
import * as xml2js from 'xml2js';
88
import * as tmp from 'tmp';
99
import {URL} from 'url';
@@ -293,15 +293,19 @@ export class IIQCommands {
293293
let env = uri.fsPath.split(path.sep);
294294
result.push(env[env.length - 2].substring(4));
295295
});
296-
return result;
297296
}else{
298297
const uris = await vscode.workspace.findFiles(`**/*.target.properties`);
299298
uris.forEach((uri) => {
300299
let [env, rest] = path.basename(uri.fsPath).split(".");
301300
result.push(env);
302301
});
303-
return result;
304302
}
303+
304+
// Unique values only
305+
result = [...new Set(result)];
306+
307+
return result;
308+
305309
}
306310

307311
public getBaseSSBFolder(): string | null {
@@ -346,19 +350,21 @@ export class IIQCommands {
346350
if(0 == uris.length){
347351
return null;
348352
}
349-
var uri = uris[0];
350-
var filePath: string = uri.fsPath;
353+
const uri = uris[0];
354+
const filePath: string = uri.fsPath;
351355

352356
if(this.canUseCachedProp(filePath)){
353357
return this.g_props[filePath]["props"];
354358
}
355359

356360
this.g_props[filePath] = {"mtime": null, "props": {}};
357361
this.g_props[filePath]["mtime"] = fs.statSync(filePath).mtime;
358-
console.log(`Trying to read ${filePath} file`);
359-
var properties = propertiesReader(filePath).getAllProperties();
360-
for (var key in properties){
361-
var val: string = properties[key].toString();
362+
this.g_iiqOutput.appendLine(`Trying to read ${filePath} file`);
363+
let properties = getProperties(fs.readFileSync(filePath));
364+
365+
// Is this needed?
366+
for (let key in properties){
367+
let val: string = properties[key].toString();
362368
properties[key] = val.replace(/\\\\/g, "\\");
363369
};
364370

@@ -388,7 +394,7 @@ export class IIQCommands {
388394
}else{
389395
secretProps = await this.getFileProperties(`${environment}.target.secret.properties`);
390396
}
391-
var allProps = Object.assign({}, mainProps, secretProps);
397+
const allProps = Object.assign({}, mainProps, secretProps);
392398
return allProps;
393399
}
394400

@@ -1453,7 +1459,12 @@ export class IIQCommands {
14531459

14541460
}
14551461

1456-
private async tokenizeWithDirectTokens(xml){
1462+
/**
1463+
* Tokenizes the given XML string by replacing the tokens in the XML with their values from the properties
1464+
* @param xml The XML string to tokenize.
1465+
* @returns The tokenized XML string.
1466+
*/
1467+
private async tokenizeWithDirectTokens(xml: string): Promise<string> {
14571468
const exclusions = [
14581469
"%%ECLIPSE_URL%%",
14591470
"%%ECLIPSE_USER%%",
@@ -1462,7 +1473,7 @@ export class IIQCommands {
14621473
];
14631474
const props = await this.loadTargetProps();
14641475
const ignoreProps = await this.loadTokensToIgnore();
1465-
var ignorePropsList = Object.keys(ignoreProps);
1476+
let ignorePropsList = Object.keys(ignoreProps);
14661477
try {
14671478
for (let key in props){
14681479
if(exclusions.includes(key) || ignorePropsList.includes(key)){
@@ -1520,12 +1531,11 @@ export class IIQCommands {
15201531
return result;
15211532
}
15221533

1523-
private async tokenizeIIQObject(xml){
1534+
private async tokenizeIIQObject(xml: string): Promise<string> {
15241535
const reverseTokens = await this.loadReverseTokens();
1525-
if(reverseTokens){
1536+
if (reverseTokens) {
15261537
return await this.tokenizeWithReverseTokens(xml);
1527-
}
1528-
else{
1538+
} else {
15291539
return await this.tokenizeWithDirectTokens(xml);
15301540
}
15311541
}

package-lock.json

Lines changed: 16 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Sailpoint IIQ Development Accelerator",
44
"description": "Provides commands to facilitate/accelerate coding/interacting with remote Sailpoint IIQ server",
55
"icon": "images/icon.png",
6-
"version": "10.0.58",
6+
"version": "10.0.59",
77
"engines": {
88
"vscode": "^1.60.0"
99
},
@@ -393,7 +393,7 @@
393393
"base-64": "^1.0.0",
394394
"fast-glob": "^3.2.8",
395395
"node-fetch": "^2.6.7",
396-
"properties-reader": "^2.2.0",
396+
"properties-file": "^3.6.0",
397397
"saxon-js": "^2.6.0",
398398
"semver": "^7.5.4",
399399
"tmp": "^0.2.1",

server/package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)