From 53b366e7adbda9a5a77bbdfd909a9ac6f9d92082 Mon Sep 17 00:00:00 2001 From: Doron Sharon Date: Wed, 21 Oct 2020 15:19:30 +0300 Subject: [PATCH 1/2] Escape key chars --- lib/leaf.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/leaf.js b/lib/leaf.js index 973b507..1327f1d 100644 --- a/lib/leaf.js +++ b/lib/leaf.js @@ -175,10 +175,17 @@ var Leaf = createClass({ nextDTPath: function(key, data){ var dataType = type(data); var currentDTPath = (this.props.DTPath) ? this.props.DTPath + '.' : ''; + const readyKey = key + .replace(/\\/g, '\\\\') + .replace(/\./g, '\\.') + .replace(/"/g, '\\\"') + .replace(/'/g, '\\\'') + .replace(/\(/g, '\\(') + .replace(/\)/g, '\\)'); if (dataType === 'Array') { - return currentDTPath + '[' + key + ']'; + return currentDTPath + '[' + readyKey + ']'; } - return currentDTPath + '' + key; + return currentDTPath + '' + readyKey; }, data: function() { return this.state.original || this.props.data; From 29713c462679b912ebc32a6f5b145989b6ee93a1 Mon Sep 17 00:00:00 2001 From: Doron Sharon Date: Wed, 21 Oct 2020 15:22:11 +0300 Subject: [PATCH 2/2] Escape key chars --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ab2743..e13bfd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-json-inspector-demisto", - "version": "1.0.5", + "version": "1.0.6", "description": "React JSON inspector component", "main": "json-inspector.js", "author": {