diff --git a/core/src/main/java/hudson/markup/MarkupFormatter.java b/core/src/main/java/hudson/markup/MarkupFormatter.java index a3bf53a739a1..95af637af974 100644 --- a/core/src/main/java/hudson/markup/MarkupFormatter.java +++ b/core/src/main/java/hudson/markup/MarkupFormatter.java @@ -62,9 +62,14 @@ * This is an extension point in Hudson, allowing plugins to implement different markup formatters. * *
- * Implement the following methods to enable and control CodeMirror syntax highlighting - * public String getCodeMirrorMode() // return null to disable CodeMirror dynamically - * public String getCodeMirrorConfig() + * Implement the following methods to enable and control CodeMirror syntax highlighting: + *
public String getCodeMirrorMode()
(return null
to disable CodeMirror dynamically)public String getCodeMirrorConfig()
(JSON snippet without surrounding curly braces, e.g., "mode": "text/css"
.
+ * Historically this allowed invalid JSON, but since TODO it needs to be properly quoted etc.
+ *
diff --git a/core/src/main/resources/hudson/tasks/Shell/config.groovy b/core/src/main/resources/hudson/tasks/Shell/config.groovy
index f895ffe88f3e..bfd163196917 100644
--- a/core/src/main/resources/hudson/tasks/Shell/config.groovy
+++ b/core/src/main/resources/hudson/tasks/Shell/config.groovy
@@ -25,7 +25,7 @@ package hudson.tasks.Shell
f=namespace(lib.FormTagLib)
f.entry(title:_("Command"),description:_("description",rootURL)) {
- f.textarea(name: "command", value: instance?.command, class: "fixed-width", 'codemirror-mode': 'shell', 'codemirror-config': "mode: 'text/x-sh'")
+ f.textarea(name: "command", value: instance?.command, class: "fixed-width", 'codemirror-mode': 'shell', 'codemirror-config': '"mode": "text/x-sh"')
}
f.advanced() {
diff --git a/core/src/main/resources/lib/form/textarea/textarea.js b/core/src/main/resources/lib/form/textarea/textarea.js
index 1677e11fdd16..e1253cdfdab7 100644
--- a/core/src/main/resources/lib/form/textarea/textarea.js
+++ b/core/src/main/resources/lib/form/textarea/textarea.js
@@ -3,7 +3,28 @@ Behaviour.specify("TEXTAREA.codemirror", "textarea", 0, function (e) {
if (!config) {
config = "";
}
- config = eval("({" + config + "})");
+ try {
+ config = JSON.parse("{" + config + "}");
+ } catch (ex) {
+ /*
+ * Attempt to parse fairly common legacy format whose exact content is:
+ * mode:'