From 1f864a846f444b88151b8b28ec11bc4ea4419210 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Fri, 18 Aug 2017 17:18:38 -0500 Subject: [PATCH] Escape newline chars in conditionalPanel expr. Fixes #1818 --- NEWS.md | 2 ++ srcjs/utils.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 8c20232d9..98a5bba5e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,8 @@ shiny 1.0.4.9000 ### Bug fixes +* Fixed [#1818](https://github.com/rstudio/shiny/issues/1818): `conditionalPanel()` expressions that have a newline character in them caused the application to not work. ([#1820](https://github.com/rstudio/shiny/pull/1820)) + ### Library updates diff --git a/srcjs/utils.js b/srcjs/utils.js index f85139fda..3720c208f 100644 --- a/srcjs/utils.js +++ b/srcjs/utils.js @@ -161,7 +161,11 @@ function pixelRatio() { // "with" on the argument value, and return the result. function scopeExprToFunc(expr) { /*jshint evil: true */ - var expr_escaped = expr.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0'); + var expr_escaped = expr + .replace(/[\\"']/g, '\\$&') + .replace(/\u0000/g, '\\0') + .replace(/\n/g, '\\n'); + try { var func = new Function( `with (this) {