Skip to content

Commit

Permalink
Merge branch 'QA_3_5'
Browse files Browse the repository at this point in the history
Conflicts:
	libraries/common.lib.php
	po/uk.po
	tbl_change.php
	test/libraries/common/PMA_extractColumnSpec_test.php
  • Loading branch information
roccivic committed Jan 21, 2013
2 parents 75e7e9e + bf278f3 commit 58998ed
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 71 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -88,6 +88,7 @@ VerboseMultiSubmit, ReplaceHelpImg
- Upgraded CodeMirror to 2.37

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
Expand Down
65 changes: 9 additions & 56 deletions libraries/Util.class.php
Expand Up @@ -3046,61 +3046,7 @@ public static function extractColumnSpec($columnspec)

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($columnspec[$index])) {

// Grab the char to look at
$char = $columnspec[$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($columnspec[$index + 1]);
$next = $has_next ? $columnspec[$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($columnspec[$index + 1])
&& "'" == $columnspec[$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 = self::parseEnumSetValues($columnspec, false);
$printtype = $type
. '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
$binary = false;
Expand Down Expand Up @@ -4031,10 +3977,11 @@ public static function getButton()
*
* @param string $definition The definition of the column
* for which to parse the values
* @param bool $escapeHtml Whether to escape html entitites
*
* @return array
*/
public static function parseEnumSetValues($definition)
public static function parseEnumSetValues($definition, $escapeHtml = true)
{
$values_string = htmlentities($definition);
// There is a JS port of the below parser in functions.js
Expand Down Expand Up @@ -4074,6 +4021,12 @@ public static function parseEnumSetValues($definition)
$values[] = $buffer;
}

if (! $escapeHtml) {
foreach ($values as $key => $value) {
$values[$key] = html_entity_decode($value, ENT_QUOTES);
}
}

return $values;
}

Expand Down
2 changes: 0 additions & 2 deletions libraries/insert_edit.lib.php
Expand Up @@ -888,8 +888,6 @@ function PMA_getColumnEnumValues($column, $extracted_columnspec)
{
$column['values'] = array();
foreach ($extracted_columnspec['enum_set_values'] as $val) {
// Removes automatic MySQL escape format
$val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
$column['values'][] = array(
'plain' => $val,
'html' => htmlspecialchars($val),
Expand Down
41 changes: 28 additions & 13 deletions test/libraries/common/PMA_extractColumnSpec_test.php
Expand Up @@ -57,9 +57,9 @@ public function provider()
'enum_set_values' => array('a', 'b'),
'attribute' => ' ',
'can_contain_collation' => true,
'displayed_type' => "set('a', 'b')",
),
'displayed_type' => "set('a', 'b')"
),
),
array(
"SET('\'a','b')",
array(
Expand All @@ -72,9 +72,9 @@ public function provider()
'enum_set_values' => array("'a", 'b'),
'attribute' => ' ',
'can_contain_collation' => true,
'displayed_type' => "set('\'a', 'b')",
),
'displayed_type' => "set('\'a', 'b')"
),
),
array(
"SET('''a','b')",
array(
Expand All @@ -87,9 +87,24 @@ public function provider()
'enum_set_values' => array("'a", 'b'),
'attribute' => ' ',
'can_contain_collation' => true,
'displayed_type' => "set('''a', 'b')",
),
'displayed_type' => "set('''a', 'b')"
),
),
array(
"ENUM('a&b', 'b''c\\'d', 'e\\\\f')",
array(
'type' => 'enum',
'print_type' => "enum('a&b', 'b''c\\'d', 'e\\\\f')",
'binary' => false,
'unsigned' => false,
'zerofill' => false,
'spec_in_brackets' => "'a&b', 'b''c\\'d', 'e\\\\f'",
'enum_set_values' => array('a&b', 'b\'c\'d', 'e\\f'),
'attribute' => ' ',
'can_contain_collation' => true,
'displayed_type' => "enum('a&b', 'b''c\\'d', 'e\\\\f')"
),
),
array(
"INT UNSIGNED zerofill",
array(
Expand All @@ -102,9 +117,9 @@ public function provider()
'enum_set_values' => array(),
'attribute' => 'UNSIGNED ZEROFILL',
'can_contain_collation' => false,
'displayed_type' => "int",
),
'displayed_type' => "int"
),
),
array(
"VARCHAR(255)",
array(
Expand All @@ -117,9 +132,9 @@ public function provider()
'enum_set_values' => array(),
'attribute' => ' ',
'can_contain_collation' => true,
'displayed_type' => "varchar(255)",
),
'displayed_type' => "varchar(255)"
),
),
array(
"VARBINARY(255)",
array(
Expand All @@ -132,9 +147,9 @@ public function provider()
'enum_set_values' => array(),
'attribute' => ' ',
'can_contain_collation' => false,
'displayed_type' => "varbinary(255)",
),
'displayed_type' => "varbinary(255)"
),
);
),
);
}
}

0 comments on commit 58998ed

Please sign in to comment.