Throw exception on invalid table names

This commit is contained in:
Leonel Quinteros 2015-03-27 20:32:03 -03:00
parent 083c98ae75
commit 3b57a3c42a

View File

@ -105,7 +105,7 @@ class Toml
if($tableName == "")
{
// Empty table name
throw new Exception("Empty table keys aren't allowed on line " . $line);
throw new Exception("Empty table keys aren't allowed");
}
$tableName = trim($tableName);
@ -115,6 +115,11 @@ class Toml
{
$tableName = json_decode($tableName);
}
elseif(!ctype_alnum(str_replace(array('-', '_', '.'), '', $tableName))) // Check for proper keys
{
// Invalid table name
throw new Exception("Invalid table name: " . $tableName);
}
if( !isset($pointer[$tableName]) )
{
@ -145,6 +150,11 @@ class Toml
{
$tableName = json_decode($tableName);
}
elseif(!ctype_alnum(str_replace(array('-', '_', '.'), '', $tableName))) // Check for proper keys
{
// Invalid table name
throw new Exception("Invalid table name: " . $tableName);
}
$aTable = explode('.', $tableName);
$last = count($aTable) - 1;