diff --git a/rdap/start_rdap.php b/rdap/start_rdap.php index f71fcee..2c54ac2 100644 --- a/rdap/start_rdap.php +++ b/rdap/start_rdap.php @@ -172,7 +172,8 @@ $http->start(); function handleDomainQuery($request, $response, $pdo, $domainName, $c, $log) { // Extract and validate the domain name from the request - $domain = trim($domainName); + $domain = urldecode($domainName); + $domain = trim($domain); // Empty domain check if (!$domain) { @@ -1013,7 +1014,8 @@ function handleEntityQuery($request, $response, $pdo, $entityHandle, $c, $log) { function handleNameserverQuery($request, $response, $pdo, $nameserverHandle, $c, $log) { // Extract and validate the nameserver handle from the request - $ns = trim($nameserverHandle); + $ns = urldecode($nameserverHandle); + $ns = trim($ns); // Empty nameserver check if (!$ns) { @@ -1375,8 +1377,9 @@ function handleNameserverQuery($request, $response, $pdo, $nameserverHandle, $c, function handleDomainSearchQuery($request, $response, $pdo, $searchPattern, $c, $log, $searchType) { // Extract and validate the domain name from the request - $domain = trim($searchPattern); - + $domain = urldecode($searchPattern); + $domain = trim($domain); + // Empty domain check if (!$domain) { $response->header('Content-Type', 'application/json'); @@ -1946,7 +1949,8 @@ function handleDomainSearchQuery($request, $response, $pdo, $searchPattern, $c, function handleNameserverSearchQuery($request, $response, $pdo, $searchPattern, $c, $log, $searchType) { // Extract and validate the nameserver handle from the request - $ns = trim($searchPattern); + $ns = urldecode($searchPattern); + $ns = trim($ns); // Perform the RDAP lookup try { diff --git a/whois/port43/start_whois.php b/whois/port43/start_whois.php index 785b176..66d424f 100644 --- a/whois/port43/start_whois.php +++ b/whois/port43/start_whois.php @@ -169,8 +169,20 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pool $clidF = $stmt3->fetch(PDO::FETCH_ASSOC); + // Check if the domain name is non-ASCII or starts with 'xn--' + $isNonAsciiOrPunycode = !mb_check_encoding($f['name'], 'ASCII') || strpos($f['name'], 'xn--') === 0; + $res = "Domain Name: ".strtoupper($f['name']) - ."\nRegistry Domain ID: D".$f['id']."-".$c['roid'] + ."\n"; + + // Add the Internationalized Domain Name line if the condition is met + if ($isNonAsciiOrPunycode) { + // Convert the domain name to UTF-8 and make it uppercase + $internationalizedName = idn_to_utf8($f['name'], 0, INTL_IDNA_VARIANT_UTS46); + $res .= "Internationalized Domain Name: " . mb_strtoupper($internationalizedName) . "\n"; + } + + $res .= "Registry Domain ID: D".$f['id']."-".$c['roid'] ."\nRegistrar WHOIS Server: ".$clidF['whois_server'] ."\nRegistrar URL: ".$clidF['url'] ."\nUpdated Date: ".$f['lastupdate'] diff --git a/whois/web/check.php b/whois/web/check.php index db57a22..41a950a 100644 --- a/whois/web/check.php +++ b/whois/web/check.php @@ -19,6 +19,20 @@ $rdapServer = 'https://' . $c['rdap_url'] . '/domain/'; $sanitized_domain = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); +// Check if the domain is in Unicode and convert it to Punycode +if (mb_check_encoding($domain, 'UTF-8') && !filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { + $punycodeDomain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); + + if ($punycodeDomain !== false) { + $domain = $punycodeDomain; + } else { + echo json_encode(['error' => 'Invalid domain.']); + exit; + } +} + +$sanitized_domain = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); + if ($sanitized_domain) { $domain = $sanitized_domain; } else {