[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_6-21410-g0683bd4

Rouslan Placella roccivic at users.sourceforge.net
Fri Oct 21 16:42:56 CEST 2011


The branch, master has been updated
       via  0683bd485b73bb8297da67fa66f7a095b32e7231 (commit)
       via  0112ff6ba522b6d18fee298357a3fda1d9cea0cf (commit)
      from  20a57d1feaf48102c768ca678b695ba06ac3f340 (commit)


- Log -----------------------------------------------------------------
commit 0683bd485b73bb8297da67fa66f7a095b32e7231
Merge: 20a57d1 0112ff6
Author: Rouslan Placella <rouslan at placella.com>
Date:   Fri Oct 21 15:40:58 2011 +0100

    Merge branch 'QA_3_4'

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog       |    1 +
 js/functions.js |   58 ++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c59a9f0..b4bc408 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,6 +54,7 @@ phpMyAdmin - ChangeLog
 
 3.4.8.0 (not yet released)
 - 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)
 - bug #3418610 [interface] Links in navigation when $cfg['MainPageIconic'] = false
diff --git a/js/functions.js b/js/functions.js
index d39e387..dcd8f0f 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2609,24 +2609,48 @@ $(document).ready(function() {
         var h3_text = $("#enum_editor h3").html();
         $("#enum_editor h3").html(h3_text.split('"')[0]+'"'+column_name+'"');
 
-        // Get the values
-        var values = $(this).parent().prev("input").attr("value").split(",");
-        $.each(values, function(index, val) {
-            if(jQuery.trim(val) != "") {
-                 // enclose the string in single quotes if it's not already
-                 if(val.substr(0, 1) != "'") {
-                      val = "'" + val;
-                 }
-                 if(val.substr(val.length-1, val.length) != "'") {
-                      val = val + "'";
-                 }
-                // escape the single quotes, except the mandatory ones enclosing the entire string
-                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 + "' />");
+        // Get the values as a string
+        var inputstring = $(this)
+            .parent()
+            .prev("input")
+            .val();
+        // Escape html entities
+        inputstring = $('<div/>')
+            .text(inputstring)
+            .html();
+        // Parse the values, escaping quotes and
+        // slashes on the fly, into an array
+        var values = [];
+        var in_string = false;
+        var curr, next, buffer = '';
+        for (var i=0; i<inputstring.length; i++) {
+            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
         $("#enum_editor").append("<input type='hidden' value='" + $(this).parent().prev("input").attr("id") + "' />");
         return false;


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list