Forráskód Böngészése

ht: Allow domains ending with a dot

Miraty 2 éve
szülő
commit
f06e42645a
2 módosított fájl, 8 hozzáadás és 2 törlés
  1. 7 1
      fn/ht.php
  2. 1 1
      pages/ht/add-http-dns.php

+ 7 - 1
fn/ht.php

@@ -3,7 +3,13 @@
 function checkDomainFormat($domain) {
 	// If the domain must end without a dot
 	if (!filter_var($domain, FILTER_VALIDATE_DOMAIN) OR !preg_match("/^([a-z0-9_-]{1,63}\.){1,126}[a-z0-9]{1,63}$/", $domain))
-		userError("Wrong domain.");
+		userError("Domain malformed.");
+}
+
+function formatDomain($domain) {
+	$domain = rtrim(strtolower($domain), '.');
+	checkDomainFormat($domain);
+	return $domain;
 }
 
 function listFsDirs($username) {

+ 1 - 1
pages/ht/add-http-dns.php

@@ -6,7 +6,7 @@ else
 	$dirsStatuses = [];
 
 if (processForm()) {
-	checkDomainFormat($_POST['domain']);
+	$_POST['domain'] = formatDomain($_POST['domain']);
 
 	if ($dirsStatuses[$_POST['dir']] !== false)
 		userError("Wrong value for <code>dir</code>.");