diff --git a/app/client/package.json b/app/client/package.json index 3535b73cda..0414ddeb1d 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -81,7 +81,8 @@ "styled-components": "^4.1.3", "tinycolor2": "^1.4.1", "ts-loader": "^6.0.4", - "typescript": "^3.6.3" + "typescript": "^3.6.3", + "unescape-js": "^1.1.4" }, "scripts": { "analyze": "source-map-explorer 'build/static/js/*.js'", diff --git a/app/client/src/utils/DynamicBindingUtils.ts b/app/client/src/utils/DynamicBindingUtils.ts index 2eff683d39..b365337093 100644 --- a/app/client/src/utils/DynamicBindingUtils.ts +++ b/app/client/src/utils/DynamicBindingUtils.ts @@ -4,6 +4,7 @@ import { DATA_BIND_REGEX } from "constants/BindingsConstants"; import ValidationFactory from "./ValidationFactory"; import JSExecutionManagerSingleton from "jsExecution/JSExecutionManagerSingleton"; import { NameBindingsWithData } from "selectors/nameBindingsWithDataSelector"; +import unescapeJS from "unescape-js"; export const isDynamicValue = (value: string): boolean => DATA_BIND_REGEX.test(value); @@ -72,7 +73,8 @@ export const evaluateDynamicBoundValue = ( data: NameBindingsWithData, path: string, ): any => { - return JSExecutionManagerSingleton.evaluateSync(path, data); + const unescapedInput = unescapeJS(path); + return JSExecutionManagerSingleton.evaluateSync(unescapedInput, data); }; // For creating a final value where bindings could be in a template format diff --git a/app/client/typings/unescape-js/index.d.ts b/app/client/typings/unescape-js/index.d.ts new file mode 100644 index 0000000000..cfd13f9310 --- /dev/null +++ b/app/client/typings/unescape-js/index.d.ts @@ -0,0 +1 @@ +declare module "unescape-js"; diff --git a/app/client/yarn.lock b/app/client/yarn.lock index f5a215344e..e04df909b4 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -14108,6 +14108,11 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.fromcodepoint@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/string.fromcodepoint/-/string.fromcodepoint-0.2.1.tgz#8d978333c0bc92538f50f383e4888f3e5619d653" + integrity sha1-jZeDM8C8klOPUPOD5IiPPlYZ1lM= + "string.prototype.matchall@^4.0.0 || ^3.0.1": version "4.0.2" resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz#48bb510326fb9fdeb6a33ceaa81a6ea04ef7648e" @@ -14827,6 +14832,13 @@ uglify-js@^3.1.4: commander "~2.20.3" source-map "~0.6.1" +unescape-js@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/unescape-js/-/unescape-js-1.1.4.tgz#4bc6389c499cb055a98364a0b3094e1c3d5da395" + integrity sha512-42SD8NOQEhdYntEiUQdYq/1V/YHwr1HLwlHuTJB5InVVdOSbgI6xu8jK5q65yIzuFCfczzyDF/7hbGzVbyCw0g== + dependencies: + string.fromcodepoint "^0.2.1" + unfetch@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db"