Small EPP server fixes

This commit is contained in:
Pinga 2024-01-24 14:01:02 +02:00
parent 34da89751d
commit fa869fef75

View file

@ -98,7 +98,7 @@ function sendGreeting($conn) {
function sendEppError($conn, $db, $code, $msg, $clTRID = "000", $trans = "0") { function sendEppError($conn, $db, $code, $msg, $clTRID = "000", $trans = "0") {
if (!isset($clTRID)) { if (!isset($clTRID)) {
$clTRID = "000"; $clTRID = 'client-not-provided-' . bin2hex(random_bytes(8));
} }
if (!isset($trans)) { if (!isset($trans)) {
$trans = "0"; $trans = "0";
@ -190,10 +190,10 @@ function validate_label($label, $pdo) {
return 'You must enter a domain name'; return 'You must enter a domain name';
} }
if (strlen($label) > 63) { if (strlen($label) > 63) {
return 'Total lenght of your domain must be less then 63 characters'; return 'Total length of your domain must be less then 63 characters';
} }
if (strlen($label) < 2) { if (strlen($label) < 2) {
return 'Total lenght of your domain must be greater then 2 characters'; return 'Total length of your domain must be greater then 2 characters';
} }
if (strpos($label, 'xn--') === false && preg_match("/(^-|^\.|-\.|\.-|--|\.\.|-$|\.$)/", $label)) { if (strpos($label, 'xn--') === false && preg_match("/(^-|^\.|-\.|\.-|--|\.\.|-$|\.$)/", $label)) {
return 'Invalid domain name format, cannot begin or end with a hyphen (-)'; return 'Invalid domain name format, cannot begin or end with a hyphen (-)';
@ -337,6 +337,11 @@ function createTransaction($db, $clid, $clTRID, $clTRIDframe) {
$clTRID = 'client-not-provided-' . bin2hex(random_bytes(8)); // Generates a 16 character hexadecimal string $clTRID = 'client-not-provided-' . bin2hex(random_bytes(8)); // Generates a 16 character hexadecimal string
} }
if (empty($clid)) {
// If $clid is empty, throw an exception
throw new Exception("Malformed command received.");
}
// Execute the statement // Execute the statement
if (!$stmt->execute([ if (!$stmt->execute([
$clid, $clid,