Fixed bug #3426840 - ENUM/SET editor can't handle commas in values
This commit is contained in:
@@ -3,6 +3,7 @@ phpMyAdmin - ChangeLog
|
|||||||
|
|
||||||
3.4.8.0 (not yet released)
|
3.4.8.0 (not yet released)
|
||||||
- bug #3425230 [interface] enum data split at space char (more space to edit)
|
- bug #3425230 [interface] enum data split at space char (more space to edit)
|
||||||
|
- bug #3426840 [interface] ENUM/SET editor can't handle commas in values
|
||||||
|
|
||||||
3.4.7.0 (not yet released)
|
3.4.7.0 (not yet released)
|
||||||
- bug #3418610 [interface] Links in navigation when $cfg['MainPageIconic'] = false
|
- bug #3418610 [interface] Links in navigation when $cfg['MainPageIconic'] = false
|
||||||
|
@@ -1842,24 +1842,48 @@ $(document).ready(function() {
|
|||||||
$("#popup_background").fadeIn("fast");
|
$("#popup_background").fadeIn("fast");
|
||||||
$("#enum_editor").fadeIn("fast");
|
$("#enum_editor").fadeIn("fast");
|
||||||
|
|
||||||
// Get the values
|
// Get the values as a string
|
||||||
var values = $(this).parent().prev("input").attr("value").split(",");
|
var inputstring = $(this)
|
||||||
$.each(values, function(index, val) {
|
.parent()
|
||||||
if(jQuery.trim(val) != "") {
|
.prev("input")
|
||||||
// enclose the string in single quotes if it's not already
|
.val();
|
||||||
if(val.substr(0, 1) != "'") {
|
// Escape html entities
|
||||||
val = "'" + val;
|
inputstring = $('<div/>')
|
||||||
}
|
.text(inputstring)
|
||||||
if(val.substr(val.length-1, val.length) != "'") {
|
.html();
|
||||||
val = val + "'";
|
// Parse the values, escaping quotes and
|
||||||
}
|
// slashes on the fly, into an array
|
||||||
// escape the single quotes, except the mandatory ones enclosing the entire string
|
var values = [];
|
||||||
val = val.substr(1, val.length-2).replace(/''/g, "'").replace(/\\\\/g, '\\').replace(/\\'/g, "'").replace(/'/g, "'");
|
var in_string = false;
|
||||||
// escape the greater-than symbol
|
var curr, next, buffer = '';
|
||||||
val = val.replace(/>/g, ">");
|
for (var i=0; i<inputstring.length; i++) {
|
||||||
$("#enum_editor #values").append("<input type='text' value='" + val + "' />");
|
curr = inputstring.charAt(i);
|
||||||
|
next = i == inputstring.length ? '' : inputstring.charAt(i+1);
|
||||||
|
if (! in_string && curr == "'") {
|
||||||
|
in_string = true;
|
||||||
|
} else if (in_string && curr == "\\" && next == "\\") {
|
||||||
|
buffer += "\";
|
||||||
|
i++;
|
||||||
|
} else if (in_string && next == "'" && (curr == "'" || curr == "\\")) {
|
||||||
|
buffer += "'";
|
||||||
|
i++;
|
||||||
|
} else if (in_string && curr == "'") {
|
||||||
|
in_string = false;
|
||||||
|
values.push(buffer);
|
||||||
|
buffer = '';
|
||||||
|
} else if (in_string) {
|
||||||
|
buffer += curr;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
if (buffer.length > 0) {
|
||||||
|
values.push(buffer);
|
||||||
|
}
|
||||||
|
// Add the parsed values to the editor
|
||||||
|
for (var i=0; i<values.length; i++) {
|
||||||
|
$("#enum_editor #values").append(
|
||||||
|
"<input type='text' value='" + values[i] + "' />"
|
||||||
|
);
|
||||||
|
}
|
||||||
// So we know which column's data is being edited
|
// So we know which column's data is being edited
|
||||||
$("#enum_editor").append("<input type='hidden' value='" + $(this).parent().prev("input").attr("id") + "' />");
|
$("#enum_editor").append("<input type='hidden' value='" + $(this).parent().prev("input").attr("id") + "' />");
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user