Permalink
Browse files

Dropped custom enum/set parser. Fixes bug #3779

  • Loading branch information...
1 parent ee42a22 commit c1b00661d450e172160445201fcc0e5097c7d55a @roccivic roccivic committed Jan 21, 2013
Showing with 9 additions and 54 deletions.
  1. +1 −0 ChangeLog
  2. +8 −52 libraries/common.lib.php
  3. +0 −2 tbl_change.php
View
@@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog
======================
3.5.7.0 (not yet released)
+- bug #3779 [core] Problem with backslash in enum fields
3.5.6.0 (not yet released)
- bug #3593604 [status] Erroneous advisor rule
@@ -2927,57 +2927,7 @@ function PMA_extractFieldSpec($fieldspec)
if ('enum' == $type || 'set' == $type) {
// Define our working vars
- $enum_set_values = array();
- $working = "";
- $in_string = false;
- $index = 0;
-
- // While there is another character to process
- while (isset($fieldspec[$index])) {
- // Grab the char to look at
- $char = $fieldspec[$index];
-
- // If it is a single quote, needs to be handled specially
- if ($char == "'") {
- // If we are not currently in a string, begin one
- if (! $in_string) {
- $in_string = true;
- $working = "";
- } else {
- // Otherwise, it may be either an end of a string,
- // or a 'double quote' which can be handled as-is
- // Check out the next character (if possible)
- $has_next = isset($fieldspec[$index + 1]);
- $next = $has_next ? $fieldspec[$index + 1] : null;
-
- //If we have reached the end of our 'working' string (because
- //there are no more chars,or the next char is not another quote)
- if (! $has_next || $next != "'") {
- $enum_set_values[] = $working;
- $in_string = false;
-
- } elseif ($next == "'") {
- // Otherwise, this is a 'double quote',
- // and can be added to the working string
- $working .= "'";
- // Skip the next char; we already know what it is
- $index++;
- }
- }
- } elseif ('\\' == $char
- && isset($fieldspec[$index + 1])
- && "'" == $fieldspec[$index + 1]
- ) {
- // escaping of a quote?
- $working .= "'";
- $index++;
- } else {
- // Otherwise, add it to our working string like normal
- $working .= $char;
- }
- // Increment character index
- $index++;
- } // end while
+ $enum_set_values = PMA_parseEnumSetValues($fieldspec, false);
$printtype = $type . '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
$binary = false;
$unsigned = false;
@@ -3843,10 +3793,11 @@ function PMA_printButton()
*
* @param string $definition The definition of the column
* for which to parse the values
+ * @param bool $escapeHtml Whether to escape html entitites
*
* @return array
*/
-function PMA_parseEnumSetValues($definition)
+function PMA_parseEnumSetValues($definition, $escapeHtml = true)
{
$values_string = htmlentities($definition);
// There is a JS port of the below parser in functions.js
@@ -3878,6 +3829,11 @@ function PMA_parseEnumSetValues($definition)
// The leftovers in the buffer are the last value (if any)
$values[] = $buffer;
}
+ if (! $escapeHtml) {
+ foreach ($values as $key => $value) {
+ $values[$key] = html_entity_decode($value, ENT_QUOTES);
+ }
+ }
return $values;
}
View
@@ -702,8 +702,6 @@ class="textfield"
if (! isset($table_fields[$i]['values'])) {
$table_fields[$i]['values'] = array();
foreach ($extracted_fieldspec['enum_set_values'] as $val) {
- // Removes automatic MySQL escape format
- $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
$table_fields[$i]['values'][] = array(
'plain' => $val,
'html' => htmlspecialchars($val),

0 comments on commit c1b0066

Please sign in to comment.