Skip to content

Commit

Permalink
Allow empty string as input for ip and convert this into null
Browse files Browse the repository at this point in the history
Signed-off-by: albertlast albertlast@hotmail.de
  • Loading branch information
albertlast committed Sep 20, 2016
1 parent 9dfa087 commit 9dd5303
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/Subs-Db-mysql.php
Expand Up @@ -232,7 +232,7 @@ function smf_db_replacement__callback($matches)
break;

case 'inet':
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
return 'null';
if (!isValidIP($replacement))
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand All @@ -248,7 +248,7 @@ function smf_db_replacement__callback($matches)

foreach ($replacement as $key => $value)
{
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
$replacement[$key] = 'null';
if (!isValidIP($value))
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand Down
4 changes: 2 additions & 2 deletions Sources/Subs-Db-mysqli.php
Expand Up @@ -262,7 +262,7 @@ function smf_db_replacement__callback($matches)
break;

case 'inet':
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
return 'null';
if (!isValidIP($replacement))
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand All @@ -278,7 +278,7 @@ function smf_db_replacement__callback($matches)

foreach ($replacement as $key => $value)
{
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
$replacement[$key] = 'null';
if (!isValidIP($value))
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand Down
4 changes: 2 additions & 2 deletions Sources/Subs-Db-postgresql.php
Expand Up @@ -217,7 +217,7 @@ function smf_db_replacement__callback($matches)
break;

case 'inet':
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
return 'null';
if (inet_pton($replacement) === false)
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand All @@ -232,7 +232,7 @@ function smf_db_replacement__callback($matches)

foreach ($replacement as $key => $value)
{
if ($replacement == 'null')
if ($replacement == 'null' || $replacement == '')
$replacement[$key] = 'null';
if (!isValidIP($value))
smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
Expand Down

0 comments on commit 9dd5303

Please sign in to comment.