Forbid database with empty suffix
This commit is contained in:
Alan Garcia 2012-10-26 12:21:08 +00:00
parent 7bafc9b097
commit abeac287f0
2 changed files with 12 additions and 1 deletions

View File

@ -99,7 +99,7 @@ for($i=0;$i<count($rdb);$i++) {
</tr> </tr>
</table> </table>
<br /> <br />
<input type="submit" class="inb" name="submit" value="<?php __("Create this new MySQL database."); ?>" /> <input type="submit" class="inb" name="submit" value="<?php __("Create this new MySQL database."); ?>" onClick="return mysql_error_empty_suffix();" />
</form> </form>
<?php <?php
} }
@ -108,5 +108,12 @@ for($i=0;$i<count($rdb);$i++) {
<script type="text/javascript"> <script type="text/javascript">
document.forms['main'].pass.focus(); document.forms['main'].pass.focus();
document.forms['main'].setAttribute('autocomplete', 'off'); document.forms['main'].setAttribute('autocomplete', 'off');
function mysql_error_empty_suffix() {
if ( $("#dbn").val() == '' ) {
alert("<?php __("Error: empty database suffix.");?>");
return false;
}
}
</script> </script>
<?php include_once("foot.php"); ?> <?php include_once("foot.php"); ?>

View File

@ -226,6 +226,10 @@ class m_mysql {
$dbncomp=explode('_',$dbn); $dbncomp=explode('_',$dbn);
$dbname=$dbn; $dbname=$dbn;
$dbn=$dbncomp[1]; $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)) { if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
$err->raise("mysql",_("Database name can contain only letters and numbers")); $err->raise("mysql",_("Database name can contain only letters and numbers"));