Skip to content

Commit

Permalink
More bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Nov 23, 2024
1 parent abde99e commit 439995b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
10 changes: 5 additions & 5 deletions cp/app/Controllers/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ public function createApplication(Request $request, Response $response)
$nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null;
$nameserver_ipv4 = !empty($data['nameserver_ipv4']) ? $data['nameserver_ipv4'] : null;
$nameserver_ipv6 = !empty($data['nameserver_ipv6']) ? $data['nameserver_ipv6'] : null;

$authInfo = $data['authInfo'] ?? null;

$parts = extractDomainAndTLD($domainName);
$label = $parts['domain'];
$domain_extension = $parts['tld'];
$invalid_domain = validate_label($domainName, $db);

if ($invalid_domain) {
$this->container->get('flash')->addMessage('error', 'Error creating application: Invalid domain name');
return $response->withHeader('Location', '/application/create')->withStatus(302);
}

$parts = extractDomainAndTLD($domainName);
$label = $parts['domain'];
$domain_extension = $parts['tld'];

$valid_tld = false;
$result = $db->select('SELECT id, tld FROM domain_tld');
Expand Down
24 changes: 12 additions & 12 deletions cp/app/Controllers/DomainsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,25 @@ public function createDomain(Request $request, Response $response)
$nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null;
$nameserver_ipv4 = !empty($data['nameserver_ipv4']) ? $data['nameserver_ipv4'] : null;
$nameserver_ipv6 = !empty($data['nameserver_ipv6']) ? $data['nameserver_ipv6'] : null;

$dsKeyTag = isset($data['dsKeyTag']) ? (int)$data['dsKeyTag'] : null;
$dsAlg = $data['dsAlg'] ?? null;
$dsDigestType = isset($data['dsDigestType']) ? (int)$data['dsDigestType'] : null;
$dsDigest = $data['dsDigest'] ?? null;

$dnskeyFlags = $data['dnskeyFlags'] ?? null;
$dnskeyProtocol = $data['dnskeyProtocol'] ?? null;
$dnskeyAlg = $data['dnskeyAlg'] ?? null;
$dnskeyPubKey = $data['dnskeyPubKey'] ?? null;

$authInfo = $data['authInfo'] ?? null;

$invalid_domain = validate_label($domainName, $db);

if ($invalid_domain) {
$this->container->get('flash')->addMessage('error', 'Error creating domain: Invalid domain name');
return $response->withHeader('Location', '/domain/create')->withStatus(302);
}

try {
$parts = extractDomainAndTLD($domainName);
} catch (\Exception $e) {
Expand All @@ -179,12 +185,6 @@ public function createDomain(Request $request, Response $response)
}
$label = $parts['domain'];
$domain_extension = $parts['tld'];
$invalid_domain = validate_label($domainName, $db);

if ($invalid_domain) {
$this->container->get('flash')->addMessage('error', 'Error creating domain: Invalid domain name');
return $response->withHeader('Location', '/domain/create')->withStatus(302);
}

$valid_tld = false;
$result = $db->select('SELECT id, tld FROM domain_tld');
Expand Down Expand Up @@ -759,9 +759,9 @@ public function createDomain(Request $request, Response $response)
} else {
$currentDateTime = new \DateTime();
$host_date = $currentDateTime->format('Y-m-d H:i:s.v');

if ($internal_host) {
if (strpos(strtolower($nameserver), strtolower($domainName)) !== false) {
if (str_ends_with(strtolower(trim($nameserver)), strtolower(trim($domainName)))) {
$db->insert(
'host',
[
Expand Down
3 changes: 3 additions & 0 deletions cp/bootstrap/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ function validate_label($label, $db) {
if (strlen($label) < 2) {
return 'Total lenght of your domain must be greater then 2 characters';
}
if (strpos($label, '.') === false) {
return 'Invalid domain name format, must contain at least one dot (.)';
}
if (strpos($label, 'xn--') === false && preg_match("/(^-|^\.|-\.|\.-|--|\.\.|-$|\.$)/", $label)) {
return 'Invalid domain name format, cannot begin or end with a hyphen (-)';
}
Expand Down
8 changes: 4 additions & 4 deletions epp/src/epp-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,17 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
}
}

$parts = extractDomainAndTLD($domainName);
$label = $parts['domain'];
$domain_extension = $parts['tld'];

$invalid_domain = validate_label($domainName, $db);

if ($invalid_domain) {
sendEppError($conn, $db, 2306, 'Invalid domain:name', $clTRID, $trans);
return;
}

$parts = extractDomainAndTLD($domainName);
$label = $parts['domain'];
$domain_extension = $parts['tld'];

$valid_tld = false;
$stmt = $db->prepare("SELECT id, tld FROM domain_tld");
$stmt->execute();
Expand Down
3 changes: 3 additions & 0 deletions epp/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ function validate_label($label, $pdo) {
if (strlen($label) < 2) {
return 'Total length of your domain must be greater then 2 characters';
}
if (strpos($label, '.') === false) {
return 'Invalid domain name format, must contain at least one dot (.)';
}
if (strpos($label, 'xn--') === false && preg_match("/(^-|^\.|-\.|\.-|--|\.\.|-$|\.$)/", $label)) {
return 'Invalid domain name format, cannot begin or end with a hyphen (-)';
}
Expand Down

0 comments on commit 439995b

Please sign in to comment.