Skip to content

Commit

Permalink
Merge branch 'QA_4_6'
Browse files Browse the repository at this point in the history
Conflicts:
	po/el.po
	po/ko.po
  • Loading branch information
devenbansod committed Oct 19, 2016
2 parents b0113ea + 5dbc286 commit 7aad858
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
18 changes: 13 additions & 5 deletions libraries/Table.php
Expand Up @@ -1199,17 +1199,22 @@ static public function moveCopy($source_db, $source_table, $target_db,
* checks if given name is a valid table name,
* currently if not empty, trailing spaces, '.', '/' and '\'
*
* @param string $table_name name to check
* @param string $table_name name to check
* @param boolean $is_backquoted whether this name is used inside backquotes or not
*
* @todo add check for valid chars in filename on current system/os
* @see https://dev.mysql.com/doc/refman/5.0/en/legal-names.html
*
* @return boolean whether the string is valid or not
*/
static function isValidName($table_name)
static function isValidName($table_name, $is_backquoted = false)
{
if ($table_name !== trim($table_name)) {
// trailing spaces
if ($table_name !== rtrim($table_name)) {
// trailing spaces not allowed even in backquotes
return false;
}
if (! $is_backquoted && $table_name !== trim($table_name)) {
// spaces at the start or in between
return false;
}

Expand Down Expand Up @@ -1264,7 +1269,10 @@ function () {
return true;
}

if (! Table::isValidName($new_name)) {
// Allow whitespaces (not trailing) in $new_name,
// since we are using $backquoted in getting the fullName of table
// below to be used in the query
if (! Table::isValidName($new_name, true)) {
$this->errors[] = __('Invalid table name:') . ' '
. $new_table->getFullName();
return false;
Expand Down
5 changes: 5 additions & 0 deletions tbl_operations.php
Expand Up @@ -221,7 +221,12 @@
}
exit;
}
} else {
$_message = $result
? PMA\libraries\Message::success($_message)
: PMA\libraries\Message::error($_message);
}

if (! empty($warning_messages)) {
$_message = new PMA\libraries\Message;
$_message->addMessagesString($warning_messages);
Expand Down
8 changes: 6 additions & 2 deletions test/classes/TableTest.php
Expand Up @@ -381,11 +381,11 @@ public function testGetLastErrorAndMessage()
*
* @dataProvider dataValidateName
*/
public function testValidateName($name, $result)
public function testValidateName($name, $result, $is_backquoted=false)
{
$this->assertEquals(
$result,
Table::isValidName($name)
Table::isValidName($name, $is_backquoted)
);
}

Expand All @@ -401,6 +401,10 @@ public function dataValidateName()
array('te/st', false),
array('te.st', false),
array('te\\st', false),
array('te st', true),
array(' te st', true, true),
array('test ', false),
array('test ', false, true),
);
}

Expand Down

0 comments on commit 7aad858

Please sign in to comment.