Merge branch 'devel' into new-icon

This commit is contained in:
Dan Schaper
2016-08-19 17:18:31 -07:00
committed by GitHub
3 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -85,7 +85,8 @@ function add() {
method: "post",
data: {"domain":domain.val(), "list":list_type, "token":token},
success: function(response) {
if (response.indexOf("not a valid argument")>=0) {
if (response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0) {
alFailure.show();
alFailure.delay(1000).fadeOut(2000, function() {
alFailure.hide();
+8
View File
@@ -1,4 +1,5 @@
<?php
require('func.php');
$ERRORLOG = getenv('PHP_ERROR_LOG');
if (empty($ERRORLOG)) {
$ERRORLOG = '/var/log/lighttpd/error.log';
@@ -49,4 +50,11 @@ if(!isset($_SESSION['token'], $_POST['token']) || !hash_equals($_SESSION['token'
log_and_die("Wrong token");
}
if(isset($_POST['domain'])){
$validDomain = is_valid_domain_name($_POST['domain']);
if(!$validDomain){
log_and_die($_POST['domain']. ' is not a valid domain');
}
}
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
function is_valid_domain_name($domain_name)
{
return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) && //valid chars check
preg_match("/^.{1,253}$/", $domain_name) && //overall length check
preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)); //length of each label
}
?>