Skip to content

Commit 1f864a8

Browse files
committed
Escape newline chars in conditionalPanel expr. Fixes rstudio#1818
1 parent fc32c2c commit 1f864a8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ shiny 1.0.4.9000
1111

1212
### Bug fixes
1313

14+
* 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))
15+
1416
### Library updates
1517

1618

srcjs/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ function pixelRatio() {
161161
// "with" on the argument value, and return the result.
162162
function scopeExprToFunc(expr) {
163163
/*jshint evil: true */
164-
var expr_escaped = expr.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
164+
var expr_escaped = expr
165+
.replace(/[\\"']/g, '\\$&')
166+
.replace(/\u0000/g, '\\0')
167+
.replace(/\n/g, '\\n');
168+
165169
try {
166170
var func = new Function(
167171
`with (this) {

0 commit comments

Comments
 (0)