mirror of
https://github.com/leonelquinteros/php-toml.git
synced 2025-01-17 04:18:17 +01:00
Throw exception on invalid table names
This commit is contained in:
parent
083c98ae75
commit
3b57a3c42a
12
src/Toml.php
12
src/Toml.php
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user