diff --git a/libraries/adaptive-expressions/src/expressionProperties/stringExpression.ts b/libraries/adaptive-expressions/src/expressionProperties/stringExpression.ts index b9a94e083d..4a32f5757a 100644 --- a/libraries/adaptive-expressions/src/expressionProperties/stringExpression.ts +++ b/libraries/adaptive-expressions/src/expressionProperties/stringExpression.ts @@ -50,7 +50,7 @@ export class StringExpression extends ExpressionProperty { } // Initialize value - this.expressionText = `=\`${ value }\``; + this.expressionText = `=\`${ value.replace(/\\/g, '\\\\') }\``; return; } } diff --git a/libraries/adaptive-expressions/src/expressionProperties/valueExpression.ts b/libraries/adaptive-expressions/src/expressionProperties/valueExpression.ts index 81cada6761..d4a9636f9f 100644 --- a/libraries/adaptive-expressions/src/expressionProperties/valueExpression.ts +++ b/libraries/adaptive-expressions/src/expressionProperties/valueExpression.ts @@ -44,7 +44,7 @@ export class ValueExpression extends ExpressionProperty { } // keep the string as quoted expression, which will be literal unless string interpolation is used. - this.expressionText = `=\`${ value }\``; + this.expressionText = `=\`${ value.replace(/\\/g, '\\\\') }\``; return; } diff --git a/libraries/adaptive-expressions/tests/expressionProperty.test.ts b/libraries/adaptive-expressions/tests/expressionProperty.test.ts index 5535cb2d88..98046ad18d 100644 --- a/libraries/adaptive-expressions/tests/expressionProperty.test.ts +++ b/libraries/adaptive-expressions/tests/expressionProperty.test.ts @@ -161,6 +161,16 @@ describe('expressionProperty tests', () => { result = str.getValue(data); assert.equal(result, 'joe'); assert.equal(str.toExpression().toString(), 'test'); + + // slashes are the chars + str = new StringExpression('c:\\test\\test\\test'); + result = str.getValue(data); + assert.equal(result, 'c:\\test\\test\\test'); + + // tabs are the chars + str = new StringExpression('c:\test\test\test'); + result = str.getValue(data); + assert.equal(result, 'c:\test\test\test'); }); it('ValueExpression', () => { @@ -195,5 +205,15 @@ describe('expressionProperty tests', () => { result = val.getValue(data); assert.equal(result, undefined); assert.equal(val.toExpression().toString(), 'null'); + + // slashes are the chars + val = new ValueExpression('c:\\test\\test\\test'); + result = val.getValue(data); + assert.equal(result, 'c:\\test\\test\\test'); + + // tabs are the chars + val = new ValueExpression('c:\test\test\test'); + result = val.getValue(data); + assert.equal(result, 'c:\test\test\test'); }); }); \ No newline at end of file