On multi row change PMA gets the SQL error "Unclosed quote" if $unique_condition contains "]"
Example:
CREATE TABLE test (name varchar(255) NOT NULL);
INSERT INTO test VALUES(']');
View the table and click "Check All" then click "With selected: Change"
I think that this would be better, please give me your feedback:
Index: tbl_change.php
--- tbl_change.php (revision 12166)
+++ tbl_change.php (copie de travail)
@@ -165,7 +165,7 @@
$result = array();
$found_unique_key = false;
foreach ($primary_key_array as $key_id => $primary_key) {
- $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
+ $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . urldecode($primary_key) . ';';
$result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
$rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
$primary_keys[$key_id] = str_replace('\\', '\\\\', $primary_key);
Index: libraries/display_tbl.lib.php
===================================================================
--- libraries/display_tbl.lib.php (revision 12166)
+++ libraries/display_tbl.lib.php (copie de travail)
@@ -1047,7 +1047,7 @@
* avoid to display the delete and edit links
*/
$unique_condition = PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row);
- $unique_condition_html = htmlspecialchars($unique_condition);
+ $unique_condition_html = urlencode($unique_condition);
// 1.2 Defines the URLs for the modify/delete link(s)
Yes, this is better...
Hmm, my patch is not good for multi-row change.
Why not?
Are other values not working instead?
My patch would produce an invalid WHERE clause containing urlencoded values. But I just tested your patch and it does not work. Well, it eliminates the "Unclosed quote" message, but on the change panel, changing the value for something else does not work as the following query is generated:
UPDATE `base2_bug2496403`.`test` SET `name` = ']X' WHERE `test`.`name` = ']' LIMIT 1 ;
Ok, I will look into it again if I have some time...
Simple solution - just in another file...
see patch.diff
Merged in subversion, thanks.