Skip to content

Commit 6108935

Browse files
committed
Escape single quotes if needed
Otherwise scripts that themselves use single quotes will fail.
1 parent 4c3d64c commit 6108935

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/scijava/plugins/scripting/matlab/MATLABScriptEngine.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ public Object eval(final Reader reader) throws ScriptException {
114114
else if (line.matches(".*[\\w].*" + COMMENT + ".*")) {
115115
// We need to strip out any comments, as they consume the newline
116116
// character leading to incorrect script parsing.
117-
command.append(line.substring(0, line.indexOf(COMMENT)));
117+
line = line.substring(0, line.indexOf(COMMENT));
118+
119+
// Add escaped single quotes where needed
120+
line = line.replaceAll("'", "\''");
121+
122+
command.append(line);
118123
}
119124
else command.append(line);
120125

0 commit comments

Comments
 (0)