Skip to content

Commit

Permalink
Merge pull request #765 from verdigado/feature/validate-username
Browse files Browse the repository at this point in the history
Javascript validation of username to prevent illegal characters
  • Loading branch information
DavidGoodwin committed Sep 26, 2023
2 parents bb743df + ea121c7 commit 143a31d
Show file tree
Hide file tree
Showing 38 changed files with 97 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ function language_hook($PALANG, $language) {
// 'length_check' => function($password) { if (strlen(trim($password)) < 3) { return 'password_too_short'; } },
);

// Username legal characters
// New/changed usernames will be checked against this regular expression with javascript
// during entry, offending characters not displaying.
// For example:
// $CONF['username_legal_chars'] = '^[a-zA-Z0-9-_.]+$';
$CONF['username_legal_chars'] = '';

// Generate Password
// Generate a random password for a mailbox or admin and display it.
// If you want to automagically generate passwords set this to 'YES'.
Expand Down
2 changes: 2 additions & 0 deletions languages/bg.lang
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/ca.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Caràcter il·legal';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = '非法性质';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/cs.lang
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ $PALANG['password_expiration_desc'] = 'Datum expirace hesla';
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Nelegální charakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/da.lang
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Ulovlig figur';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ $PALANG['password_expiration_desc'] = 'Datum, an dem das Passwort abläuft';
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegaler Charakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 1 addition & 1 deletion languages/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire';

$PALANG['To_Mailbox'] = 'Mailbox'; # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
Expand Down
2 changes: 2 additions & 0 deletions languages/es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Carácter ilegal';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/et.lang
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/eu.lang
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/fi.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Laitonta luonnetta';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/fo.lang
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Caractère illégal';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/gl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Data na que expirará o contrasinal'; # X
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/hr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/hu.lang
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegális karakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/is.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/it.lang
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Carattere illegale';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/ja.lang
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = '違法な性格';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/lt.lang
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/mk.lang
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/nb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/nl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ $PALANG['password_expiration_desc'] = 'Aantal dagen waarnaar het wachtwo
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX
$PALANG['To_Forward_Only'] = 'Alleen Doorsturen'; # XXX

$PALANG['pLegal_char_warning'] = 'Illegaal karakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/nn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/pl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Nielegalny charakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/pt-br.lang
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Característica ilegítima';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/pt-pt.lang
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ $PALANG['password_expiration_desc'] = 'Data de quando a password irá expirar';
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Característica ilegítima';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/ro.lang
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/ru.lang
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ $PALANG['password_expiration_desc'] = 'Дата истечения срока д
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Незаконный характер';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/sk.lang
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Nelegálne charakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/sl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Illegal character';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/sv.lang
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Olaglig karaktär';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/tr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ $PALANG['password_expiration_desc'] = 'Şifrenin geçerlilik süresinin doluş t
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Yasadışı karakter';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/tw.lang
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ $PALANG['password_expiration_desc'] = 'Date when password will expire'; # XXX
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = '非法性质';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
2 changes: 2 additions & 0 deletions languages/ua.lang
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ $PALANG['password_expiration_desc'] = 'Кількість днів дії пар
$PALANG['To_Mailbox'] = 'Mailbox'; # XXX # XXX
$PALANG['To_Forward_Only'] = 'Forward Only'; # XXX # XXX

$PALANG['pLegal_char_warning'] = 'Нелегальний характер';

$PALANG['please_keep_this_as_last_entry'] = ''; # needed for language-check.sh
/* vim: set expandtab ft=php softtabstop=3 tabstop=3 shiftwidth=3: */
?>
4 changes: 3 additions & 1 deletion model/MailboxHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ protected function initStruct()
# field name allow display in... type $PALANG label $PALANG description default / options / ...
# editing? form list
'username' => pacol($this->new, 1, 1, 'mail', 'pEdit_mailbox_username' , '' , '' ),
'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username' , '' , '' ),
'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username' , '' , '',
/*options*/ array('legal_chars' => Config::read('username_legal_chars'), 'legal_char_warning' => Config::lang('pLegal_char_warning'))
),
'domain' => pacol($this->new, 0, 1, 'enum', '' , '' , '',
/*options*/ $this->allowed_domains ),
# TODO: maildir: display in list is needed to include maildir in SQL result (for post_edit hook)
Expand Down
18 changes: 18 additions & 0 deletions templates/editform.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,23 @@
}
}
{if $struct.local_part.options.legal_chars }
// If set: Check for illegal characters in local part of username
// decode htmlentities
var div = document.createElement('div');
div.innerHTML = "{$struct.local_part.options.legal_char_warning}";
var decoded = div.firstChild.nodeValue;
const local_part = document.getElementsByName("value[local_part]");
local_part[0].tabIndex = -1
local_part[0].addEventListener("keydown", function(event){
var regex = new RegExp("{$struct.local_part.options.legal_chars}");
if (!regex.test(event.key)) {
event.preventDefault();
alert(decoded + ": " + event.key);
return false;
}
});
{/if}
</script>

0 comments on commit 143a31d

Please sign in to comment.