From abeac287f0ca4164d492cf0df6bee69b6c82eea5 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Fri, 26 Oct 2012 12:21:08 +0000 Subject: [PATCH] Fix #1338 Forbid database with empty suffix --- bureau/admin/sql_list.php | 9 ++++++++- bureau/class/m_mysql.php | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bureau/admin/sql_list.php b/bureau/admin/sql_list.php index b3a2b05c..75b59de4 100644 --- a/bureau/admin/sql_list.php +++ b/bureau/admin/sql_list.php @@ -99,7 +99,7 @@ for($i=0;$i
-" /> +" onClick="return mysql_error_empty_suffix();" /> document.forms['main'].pass.focus(); document.forms['main'].setAttribute('autocomplete', 'off'); + +function mysql_error_empty_suffix() { + if ( $("#dbn").val() == '' ) { + alert(""); + return false; + } +} diff --git a/bureau/class/m_mysql.php b/bureau/class/m_mysql.php index c42ae071..15f3c87f 100644 --- a/bureau/class/m_mysql.php +++ b/bureau/class/m_mysql.php @@ -226,6 +226,10 @@ class m_mysql { $dbncomp=explode('_',$dbn); $dbname=$dbn; $dbn=$dbncomp[1]; + if (empty($dbn)) { // If nothing after the '_' + $err->raise("mysql",_("Database can't have empty suffix")); + return false; + } } if (!preg_match("#^[0-9a-z]*$#",$dbn)) { $err->raise("mysql",_("Database name can contain only letters and numbers"));