Automatic escaping in js enum editor.

This commit is contained in:
Michal Čihař
2010-09-07 10:43:39 +02:00
parent 19c78d1780
commit 0e3015ce1b

View File

@@ -2380,7 +2380,7 @@ $(document).ready(function() {
val = val + "'";
}
// escape the single quotes, except the mandatory ones enclosing the entire string
val = val.substr(1, val.length-2).replace(/'/g, "'");
val = val.substr(1, val.length-2).replace(/''/g, "'").replace(/\\\\/g, '\\').replace(/\\'/g, "'").replace(/'/g, "'");
// escape the greater-than symbol
val = val.replace(/>/g, ">");
$("#enum_editor #values").append("<input type='text' value=" + val + " />");
@@ -2412,7 +2412,7 @@ $(document).ready(function() {
$.each($("#enum_editor #values input"), function(index, input_element) {
val = jQuery.trim(input_element.value);
if(val != "") {
value_array.push("'" + val + "'");
value_array.push("'" + val.replace(/\\/g, '\\\\').replace(/'/g, "''") + "'");
}
});
// get the Length/Values text field where this value belongs