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

This commit is contained in:
Miraty 2023-06-05 00:18:10 +02:00
parent 4c9e5a5580
commit f05a55a7fa
9 changed files with 68 additions and 34 deletions

View file

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

View file

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

View file

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"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"
"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"
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."
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."
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."
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."
msgstr "Adresse IP malformée."
#: fn/dns.php:68 fn/ht.php:28
#: fn/dns.php:68 fn/ht.php:30
msgid "Domain malformed."
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/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/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
msgid "Domain"
msgstr "Domaine"
#: 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"
msgstr "Dossier ciblé"
#: 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"
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
msgid "Subdomain"
msgstr "Sous-domaine"
#: 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"
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;:"
#: 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"
msgstr "Suffixe"
#: pg-view/reg/register.php:27
#: pg-view/reg/register.php:31
msgid "Check availability"
msgstr "Vérifier sa disponibilité"
#: pg-view/reg/register.php:29
#: pg-view/reg/register.php:33
msgid "Register"
msgstr "Enregistrer"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\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"
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."
msgstr ""
#: router.php:161
#: router.php:162
msgid "You need to be logged in to do this."
msgstr ""
#: router.php:163
#: router.php:164
msgid "This account doesn't exist anymore. Log out to end this ghost session."
msgstr ""
@ -348,7 +348,7 @@ msgstr ""
msgid "IP address malformed."
msgstr ""
#: fn/dns.php:68 fn/ht.php:28
#: fn/dns.php:68 fn/ht.php:30
msgid "Domain malformed."
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/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/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
msgid "Domain"
msgstr ""
#: 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"
msgstr ""
#: 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"
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
msgid "Subdomain"
msgstr ""
#: 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"
msgstr ""
@ -1138,18 +1148,18 @@ msgid "Nobody can register a domain under these suffixes:"
msgstr ""
#: 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 ""
#: 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"
msgstr ""
#: pg-view/reg/register.php:27
#: pg-view/reg/register.php:31
msgid "Check availability"
msgstr ""
#: pg-view/reg/register.php:29
#: pg-view/reg/register.php:33
msgid "Register"
msgstr ""

View file

@ -3,7 +3,7 @@
if (dirsStatuses('subdomain')[$_POST['dir']] !== false)
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.'));
if (query('select', 'sites', ['address' => $_POST['subdomain'], 'type' => 'subdomain']) !== [])

View file

@ -3,7 +3,7 @@
if (dirsStatuses('subpath')[$_POST['dir']] !== false)
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.'));
if (query('select', 'sites', ['address' => $_POST['path'], 'type' => 'subpath']) !== [])

View file

@ -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">
<label for="subdomain"><?= _('Subdomain') ?></label><br>
<input required="" placeholder="label" id="subdomain" name="subdomain" type="text"><code>.<?= CONF['ht']['subdomain_domain'] ?></code><br>

View file

@ -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">
<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>
<select required="" name="dir" id="dir">
<option value="" disabled="" selected=""></option>

View file

@ -1,5 +1,9 @@
<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>
<form method="post">