Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug #3534311 - Grid editing incorrectly parses ENUM/SET values
- Loading branch information
Showing
4 changed files
with
51 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -3839,4 +3839,48 @@ function PMA_printButton() | ||
echo '<input type="button" id="print" value="' . __('Print') . '" />'; | echo '<input type="button" id="print" value="' . __('Print') . '" />'; | ||
echo '</p>'; | echo '</p>'; | ||
} | } | ||
|
|||
/** | |||
* Parses ENUM/SET values | |||
* | |||
* @param string $definition The definition of the column | |||
* for which to parse the values | |||
* | |||
* @return array | |||
*/ | |||
function PMA_parseEnumSetValues($definition) | |||
{ | |||
$values_string = htmlentities($definition); | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
roccivic
Author
Contributor
|
|||
// There is a JS port of the below parser in functions.js | |||
// If you are fixing something here, | |||
// you need to also update the JS port. | |||
$values = array(); | |||
$in_string = false; | |||
$buffer = ''; | |||
for ($i=0; $i<strlen($values_string); $i++) { | |||
$curr = $values_string[$i]; | |||
$next = $i == strlen($values_string)-1 ? '' : $values_string[$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[] = $buffer; | |||
$buffer = ''; | |||
} else if ($in_string) { | |||
$buffer .= $curr; | |||
} | |||
} | |||
if (strlen($buffer) > 0) { | |||
// The leftovers in the buffer are the last value (if any) | |||
$values[] = $buffer; | |||
} | |||
return $values; | |||
} | |||
|
|||
?> | ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rouslan,
why htmlentities() ? See #188