Parcourir la source

Display string rules, reg: allow "-" for subdomains

Miraty il y a 2 ans
Parent
commit
f05a55a7fa

+ 2 - 0
fn/ht.php

@@ -1,5 +1,7 @@
 <?php
 <?php
 
 
+const SUBPATH_REGEX = '^[a-z0-9-]{4,63}$';
+
 function htSetupUserFs($id) {
 function htSetupUserFs($id) {
 	// Setup SFTP directory
 	// Setup SFTP directory
 	if (mkdir(CONF['ht']['ht_path'] . '/fs/' . $id, 0000) !== true)
 	if (mkdir(CONF['ht']['ht_path'] . '/fs/' . $id, 0000) !== true)

+ 1 - 1
fn/reg.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-const SUBDOMAIN_REGEX = '^[a-z0-9]{4,63}$';
+const SUBDOMAIN_REGEX = '^(?!\-)(?!..\-\-)[a-z0-9-]{4,63}(?<!\-)$';
 
 
 function regListUserDomains() {
 function regListUserDomains() {
 	if (isset($_SESSION['id']))
 	if (isset($_SESSION['id']))

+ 25 - 15
locales/fr/C/LC_MESSAGES/messages.po

@@ -1,7 +1,7 @@
 msgid ""
 msgid ""
 msgstr ""
 msgstr ""
 "Report-Msgid-Bugs-To: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-06-02 22:42+0200\n"
+"POT-Creation-Date: 2023-06-04 23:57+0200\n"
 "Language: fr\n"
 "Language: fr\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 
 
@@ -274,15 +274,15 @@ msgstr "Supprimer un accès"
 msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
 msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
 msgstr "Retirer un accès HTTP existant d'un sous-dossier de l'espace SFTP"
 msgstr "Retirer un accès HTTP existant d'un sous-dossier de l'espace SFTP"
 
 
-#: router.php:151 view.php:39
+#: router.php:152 view.php:39
 msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
 msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
 msgstr "Ce service est en cours de maintenance. Aucune action ne peut être effectuée avant qu'ane administrataire termine de le réparer."
 msgstr "Ce service est en cours de maintenance. Aucune action ne peut être effectuée avant qu'ane administrataire termine de le réparer."
 
 
-#: router.php:161
+#: router.php:162
 msgid "You need to be logged in to do this."
 msgid "You need to be logged in to do this."
 msgstr "Vous devez être connecté·e à un compte pour faire cela."
 msgstr "Vous devez être connecté·e à un compte pour faire cela."
 
 
-#: router.php:163
+#: router.php:164
 msgid "This account doesn't exist anymore. Log out to end this ghost session."
 msgid "This account doesn't exist anymore. Log out to end this ghost session."
 msgstr "Ce compte n'existe plus. Déconnectez-vous pour terminer cette session fantôme."
 msgstr "Ce compte n'existe plus. Déconnectez-vous pour terminer cette session fantôme."
 
 
@@ -336,7 +336,7 @@ msgstr "Preuve incorrecte."
 msgid "IP address malformed."
 msgid "IP address malformed."
 msgstr "Adresse IP malformée."
 msgstr "Adresse IP malformée."
 
 
-#: fn/dns.php:68 fn/ht.php:28
+#: fn/dns.php:68 fn/ht.php:30
 msgid "Domain malformed."
 msgid "Domain malformed."
 msgstr "Domaine malformé."
 msgstr "Domaine malformé."
 
 
@@ -672,28 +672,38 @@ msgstr "Le domaine doit avoir les enregistrements suivants pendant le traitement
 #: pg-view/ht/add-dns.php:29 pg-view/ns/form.ns.php:8 pg-view/ns/print.php:32
 #: pg-view/ht/add-dns.php:29 pg-view/ns/form.ns.php:8 pg-view/ns/print.php:32
 #: pg-view/ns/zone-add.php:6 pg-view/reg/ds.php:8 pg-view/reg/glue.php:8
 #: pg-view/ns/zone-add.php:6 pg-view/reg/ds.php:8 pg-view/reg/glue.php:8
 #: pg-view/reg/glue.php:15 pg-view/reg/ns.php:8 pg-view/reg/print.php:2
 #: pg-view/reg/glue.php:15 pg-view/reg/ns.php:8 pg-view/reg/print.php:2
-#: pg-view/reg/print.php:16 pg-view/reg/register.php:7
+#: pg-view/reg/print.php:16 pg-view/reg/register.php:11
 #: pg-view/reg/unregister.php:6
 #: pg-view/reg/unregister.php:6
 msgid "Domain"
 msgid "Domain"
 msgstr "Domaine"
 msgstr "Domaine"
 
 
 #: pg-view/ht/add-dns.php:31 pg-view/ht/add-onion.php:2
 #: pg-view/ht/add-dns.php:31 pg-view/ht/add-onion.php:2
-#: pg-view/ht/add-subdomain.php:4 pg-view/ht/add-subpath.php:4
+#: pg-view/ht/add-subdomain.php:8 pg-view/ht/add-subpath.php:8
 msgid "Target directory"
 msgid "Target directory"
 msgstr "Dossier ciblé"
 msgstr "Dossier ciblé"
 
 
 #: pg-view/ht/add-dns.php:40 pg-view/ht/add-onion.php:11
 #: pg-view/ht/add-dns.php:40 pg-view/ht/add-onion.php:11
-#: pg-view/ht/add-subdomain.php:13 pg-view/ht/add-subpath.php:13
+#: pg-view/ht/add-subdomain.php:17 pg-view/ht/add-subpath.php:17
 msgid "Setup access"
 msgid "Setup access"
 msgstr "Créer l'accès"
 msgstr "Créer l'accès"
 
 
-#: pg-view/ht/add-subdomain.php:2 pg-view/ns/form.ns.php:10
-#: pg-view/reg/glue.php:10 pg-view/reg/register.php:9
+#: pg-view/ht/add-subdomain.php:2 pg-view/reg/register.php:6
+#, php-format
+msgid "The subdomain can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters. It can't have an hyphen (%3$s) in first, last or both third and fourth position."
+msgstr "Le sous-domain peut uniquement contenir %1$s, %2$s et %3$s, et doit être entre 4 et 63 caractères. Il ne peut pas avoir un tiret (%3$s) en première, dernière ou à la fois troisième et quatrième position."
+
+#: pg-view/ht/add-subdomain.php:6 pg-view/ns/form.ns.php:10
+#: pg-view/reg/glue.php:10 pg-view/reg/register.php:13
 #: pg-view/reg/transfer.php:9
 #: pg-view/reg/transfer.php:9
 msgid "Subdomain"
 msgid "Subdomain"
 msgstr "Sous-domaine"
 msgstr "Sous-domaine"
 
 
 #: pg-view/ht/add-subpath.php:2
 #: pg-view/ht/add-subpath.php:2
+#, php-format
+msgid "The path can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters."
+msgstr "Le chemin peut uniquement contenir %1$s, %2$s et %3$s, et doit être entre 4 et 63 caractères."
+
+#: pg-view/ht/add-subpath.php:6
 msgid "Path"
 msgid "Path"
 msgstr "Chemin"
 msgstr "Chemin"
 
 
@@ -1126,18 +1136,18 @@ msgid "Nobody can register a domain under these suffixes:"
 msgstr "Personne ne peut enregistrer un domain sous ces suffixes&nbsp;:"
 msgstr "Personne ne peut enregistrer un domain sous ces suffixes&nbsp;:"
 
 
 #: pg-view/reg/register.php:2
 #: pg-view/reg/register.php:2
-msgid "Register a new domain on your account. It must consist of between 4 and 63 letters and digits."
-msgstr "Enregistrer un nouveau domaine sur son compte. Il doit être composé d'entre 4 et 63 lettres et chiffres."
+msgid "Register a new domain on your account."
+msgstr "Enregistrer un nouveau domaine sur son compte."
 
 
-#: pg-view/reg/register.php:14 pg-view/reg/transfer.php:14
+#: pg-view/reg/register.php:18 pg-view/reg/transfer.php:14
 msgid "Suffix"
 msgid "Suffix"
 msgstr "Suffixe"
 msgstr "Suffixe"
 
 
-#: pg-view/reg/register.php:27
+#: pg-view/reg/register.php:31
 msgid "Check availability"
 msgid "Check availability"
 msgstr "Vérifier sa disponibilité"
 msgstr "Vérifier sa disponibilité"
 
 
-#: pg-view/reg/register.php:29
+#: pg-view/reg/register.php:33
 msgid "Register"
 msgid "Register"
 msgstr "Enregistrer"
 msgstr "Enregistrer"
 
 

+ 24 - 14
locales/messages.pot

@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-06-02 22:42+0200\n"
+"POT-Creation-Date: 2023-06-04 23:57+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -286,15 +286,15 @@ msgstr ""
 msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
 msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
 msgstr ""
 msgstr ""
 
 
-#: router.php:151 view.php:39
+#: router.php:152 view.php:39
 msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
 msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
 msgstr ""
 msgstr ""
 
 
-#: router.php:161
+#: router.php:162
 msgid "You need to be logged in to do this."
 msgid "You need to be logged in to do this."
 msgstr ""
 msgstr ""
 
 
-#: router.php:163
+#: router.php:164
 msgid "This account doesn't exist anymore. Log out to end this ghost session."
 msgid "This account doesn't exist anymore. Log out to end this ghost session."
 msgstr ""
 msgstr ""
 
 
@@ -348,7 +348,7 @@ msgstr ""
 msgid "IP address malformed."
 msgid "IP address malformed."
 msgstr ""
 msgstr ""
 
 
-#: fn/dns.php:68 fn/ht.php:28
+#: fn/dns.php:68 fn/ht.php:30
 msgid "Domain malformed."
 msgid "Domain malformed."
 msgstr ""
 msgstr ""
 
 
@@ -684,28 +684,38 @@ msgstr ""
 #: pg-view/ht/add-dns.php:29 pg-view/ns/form.ns.php:8 pg-view/ns/print.php:32
 #: pg-view/ht/add-dns.php:29 pg-view/ns/form.ns.php:8 pg-view/ns/print.php:32
 #: pg-view/ns/zone-add.php:6 pg-view/reg/ds.php:8 pg-view/reg/glue.php:8
 #: pg-view/ns/zone-add.php:6 pg-view/reg/ds.php:8 pg-view/reg/glue.php:8
 #: pg-view/reg/glue.php:15 pg-view/reg/ns.php:8 pg-view/reg/print.php:2
 #: pg-view/reg/glue.php:15 pg-view/reg/ns.php:8 pg-view/reg/print.php:2
-#: pg-view/reg/print.php:16 pg-view/reg/register.php:7
+#: pg-view/reg/print.php:16 pg-view/reg/register.php:11
 #: pg-view/reg/unregister.php:6
 #: pg-view/reg/unregister.php:6
 msgid "Domain"
 msgid "Domain"
 msgstr ""
 msgstr ""
 
 
 #: pg-view/ht/add-dns.php:31 pg-view/ht/add-onion.php:2
 #: pg-view/ht/add-dns.php:31 pg-view/ht/add-onion.php:2
-#: pg-view/ht/add-subdomain.php:4 pg-view/ht/add-subpath.php:4
+#: pg-view/ht/add-subdomain.php:8 pg-view/ht/add-subpath.php:8
 msgid "Target directory"
 msgid "Target directory"
 msgstr ""
 msgstr ""
 
 
 #: pg-view/ht/add-dns.php:40 pg-view/ht/add-onion.php:11
 #: pg-view/ht/add-dns.php:40 pg-view/ht/add-onion.php:11
-#: pg-view/ht/add-subdomain.php:13 pg-view/ht/add-subpath.php:13
+#: pg-view/ht/add-subdomain.php:17 pg-view/ht/add-subpath.php:17
 msgid "Setup access"
 msgid "Setup access"
 msgstr ""
 msgstr ""
 
 
-#: pg-view/ht/add-subdomain.php:2 pg-view/ns/form.ns.php:10
-#: pg-view/reg/glue.php:10 pg-view/reg/register.php:9
+#: pg-view/ht/add-subdomain.php:2 pg-view/reg/register.php:6
+#, php-format
+msgid "The subdomain can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters. It can't have an hyphen (%3$s) in first, last or both third and fourth position."
+msgstr ""
+
+#: pg-view/ht/add-subdomain.php:6 pg-view/ns/form.ns.php:10
+#: pg-view/reg/glue.php:10 pg-view/reg/register.php:13
 #: pg-view/reg/transfer.php:9
 #: pg-view/reg/transfer.php:9
 msgid "Subdomain"
 msgid "Subdomain"
 msgstr ""
 msgstr ""
 
 
 #: pg-view/ht/add-subpath.php:2
 #: pg-view/ht/add-subpath.php:2
+#, php-format
+msgid "The path can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters."
+msgstr ""
+
+#: pg-view/ht/add-subpath.php:6
 msgid "Path"
 msgid "Path"
 msgstr ""
 msgstr ""
 
 
@@ -1138,18 +1148,18 @@ msgid "Nobody can register a domain under these suffixes:"
 msgstr ""
 msgstr ""
 
 
 #: pg-view/reg/register.php:2
 #: pg-view/reg/register.php:2
-msgid "Register a new domain on your account. It must consist of between 4 and 63 letters and digits."
+msgid "Register a new domain on your account."
 msgstr ""
 msgstr ""
 
 
-#: pg-view/reg/register.php:14 pg-view/reg/transfer.php:14
+#: pg-view/reg/register.php:18 pg-view/reg/transfer.php:14
 msgid "Suffix"
 msgid "Suffix"
 msgstr ""
 msgstr ""
 
 
-#: pg-view/reg/register.php:27
+#: pg-view/reg/register.php:31
 msgid "Check availability"
 msgid "Check availability"
 msgstr ""
 msgstr ""
 
 
-#: pg-view/reg/register.php:29
+#: pg-view/reg/register.php:33
 msgid "Register"
 msgid "Register"
 msgstr ""
 msgstr ""
 
 

+ 1 - 1
pg-act/ht/add-subdomain.php

@@ -3,7 +3,7 @@
 if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
 if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
 	output(403, 'Wrong value for <code>dir</code>.');
 	output(403, 'Wrong value for <code>dir</code>.');
 
 
-if (preg_match('/^[a-z0-9]{1,32}$/D', $_POST['subdomain']) !== 1)
+if (preg_match('/' . SUBDOMAIN_REGEX . '/D', $_POST['subdomain']) !== 1)
 	output(403, _('Invalid domain label.'));
 	output(403, _('Invalid domain label.'));
 
 
 if (query('select', 'sites', ['address' => $_POST['subdomain'], 'type' => 'subdomain']) !== [])
 if (query('select', 'sites', ['address' => $_POST['subdomain'], 'type' => 'subdomain']) !== [])

+ 1 - 1
pg-act/ht/add-subpath.php

@@ -3,7 +3,7 @@
 if (dirsStatuses('subpath')[$_POST['dir']] !== false)
 if (dirsStatuses('subpath')[$_POST['dir']] !== false)
 	output(403, 'Wrong value for <code>dir</code>.');
 	output(403, 'Wrong value for <code>dir</code>.');
 
 
-if (preg_match('/^[a-z0-9]{1,32}$/D', $_POST['path']) !== 1)
+if (preg_match('/' . SUBPATH_REGEX . '/D', $_POST['path']) !== 1)
 	output(403, _('Invalid path.'));
 	output(403, _('Invalid path.'));
 
 
 if (query('select', 'sites', ['address' => $_POST['path'], 'type' => 'subpath']) !== [])
 if (query('select', 'sites', ['address' => $_POST['path'], 'type' => 'subpath']) !== [])

+ 4 - 0
pg-view/ht/add-subdomain.php

@@ -1,3 +1,7 @@
+<p>
+	<?= sprintf(_('The subdomain can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters. It can\'t have an hyphen (%3$s) in first, last or both third and fourth position.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>',  '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>-</code>') ?>
+</p>
+
 <form method="post">
 <form method="post">
 	<label for="subdomain"><?= _('Subdomain') ?></label><br>
 	<label for="subdomain"><?= _('Subdomain') ?></label><br>
 	<input required="" placeholder="label" id="subdomain" name="subdomain" type="text"><code>.<?= CONF['ht']['subdomain_domain'] ?></code><br>
 	<input required="" placeholder="label" id="subdomain" name="subdomain" type="text"><code>.<?= CONF['ht']['subdomain_domain'] ?></code><br>

+ 5 - 1
pg-view/ht/add-subpath.php

@@ -1,6 +1,10 @@
+<p>
+	<?= sprintf(_('The path can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>',  '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>-</code>') ?>
+</p>
+
 <form method="post">
 <form method="post">
 	<label for="path"><?= _('Path') ?></label><br>
 	<label for="path"><?= _('Path') ?></label><br>
-	<code>https://<?= CONF['ht']['subpath_domain'] ?>/</code><input required="" placeholder="path" id="path" name="path" type="text"><br>
+	<code>https://<?= CONF['ht']['subpath_domain'] ?>/</code><input required="" pattern="<?= SUBPATH_REGEX ?>" placeholder="path" id="path" name="path" type="text"><br>
 	<label for="dir"><?= _('Target directory') ?></label><br>
 	<label for="dir"><?= _('Target directory') ?></label><br>
 	<select required="" name="dir" id="dir">
 	<select required="" name="dir" id="dir">
 		<option value="" disabled="" selected="">—</option>
 		<option value="" disabled="" selected="">—</option>

+ 5 - 1
pg-view/reg/register.php

@@ -1,5 +1,9 @@
 <p>
 <p>
-	<?= _('Register a new domain on your account. It must consist of between 4 and 63 letters and digits.') ?>
+	<?= _('Register a new domain on your account.') ?>
+</p>
+
+<p>
+	<?= sprintf(_('The subdomain can only contain %1$s, %2$s and %3$s, and must be between 4 and 63 characters. It can\'t have an hyphen (%3$s) in first, last or both third and fourth position.'), '<abbr title="abcdefghijklmnopqrstuvwxyz"><code>a</code>-<code>z</code></abbr>',  '<abbr title="0123456789"><code>0</code>-<code>9</code></abbr>', '<code>-</code>') ?>
 </p>
 </p>
 
 
 <form method="post">
 <form method="post">