Merge remote-tracking branch 'origin/QA_3_5' into QA_3_5

This commit is contained in:
Weblate 2013-01-21 14:37:04 +01:00
commit 724c916a6e
4 changed files with 29 additions and 61 deletions

View File

@ -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

View File

@ -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 File

@ -702,8 +702,6 @@ foreach ($rows as $row_id => $vrow) {
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),

View File

@ -46,8 +46,8 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => "'a','b'",
'enum_set_values' => array('a', 'b'),
'attribute' => ' ',
),
),
),
array(
"SET('\'a','b')",
array(
@ -59,8 +59,8 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => "'\'a','b'",
'enum_set_values' => array("'a", 'b'),
'attribute' => ' ',
),
),
),
array(
"SET('''a','b')",
array(
@ -72,8 +72,21 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => "'''a','b'",
'enum_set_values' => array("'a", 'b'),
'attribute' => ' ',
),
),
),
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' => ' ',
),
),
array(
"INT UNSIGNED zerofill",
array(
@ -85,8 +98,8 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => '',
'enum_set_values' => array(),
'attribute' => 'UNSIGNED ZEROFILL',
),
),
),
array(
"VARCHAR(255)",
array(
@ -98,8 +111,8 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => '255',
'enum_set_values' => array(),
'attribute' => ' ',
),
),
),
array(
"VARBINARY(255)",
array(
@ -111,8 +124,8 @@ class PMA_extractFieldSpec_test extends PHPUnit_Framework_TestCase
'spec_in_brackets' => '255',
'enum_set_values' => array(),
'attribute' => ' ',
),
),
);
),
);
}
}