Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Error message if there is a space at the beginning or end of username or password(login, nux, smtp, imap) #780

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions language/az.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/et.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,4 +679,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/hu.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/id.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/ja.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/pt-BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/ro.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,5 @@
'IMAP and JMAP Servers' => false,
'Junk' => false,
'Trash' => false,
'Pasted text has leading or trailing spaces' => false,
);
1 change: 1 addition & 0 deletions language/zh-Hans.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,4 +648,5 @@
'IMAP and JMAP Servers' => 'IMAP 服务器及 JMAP 服务器',
'Junk' => '垃圾',
'Trash' => '已删除',
'Pasted text has leading or trailing spaces' => false,
);
2 changes: 1 addition & 1 deletion modules/carddav_contacts/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected function output() {
}
$res .= '<tr class="carddav_settings"><td>'.$this->html_safe($name).'</td><td>';
$res .= '<input autocomplete="username" type="text" value="'.$user.'" name="carddav_usernames['.$this->html_safe($name).']" ';
$res .= 'placeholder="'.$this->trans('Username').'" class="form-control" /> <input type="password" class="form-control"';
$res .= 'placeholder="'.$this->trans('Username').'" class="form-control warn_on_paste" /> <input type="password" class="form-control warn_on_paste"';
if ($pass) {
$res .= 'disabled="disabled" placeholder="'.$this->trans('Password saved').'" ';
$res .= 'name="carddav_passwords['.$this->html_safe($name).']" /> <input type="button" ';
Expand Down
8 changes: 4 additions & 4 deletions modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ protected function output() {
<p class="text-wrap">'.$this->trans('Unsaved changes will be lost! Re-enter your password to save and exit.').' <a href="'.WEB_ROOT.'?page=save">'.$this->trans('More info').'</a></p>
<input type="text" value="'.$this->html_safe($this->get('username', 'cypht_user')).'" autocomplete="username" style="display: none;"/>
<div class="my-3 form-floating">
<input id="logout_password" autocomplete="current-password" name="password" class="form-control" type="password" placeholder="'.$this->trans('Password').'">
<input id="logout_password" autocomplete="current-password" name="password" class="form-control warn_on_paste" type="password" placeholder="'.$this->trans('Password').'">
<label for="logout_password" class="form-label screen-reader">'.$this->trans('Password').'</label>
</div>
</div>
Expand Down Expand Up @@ -1474,7 +1474,7 @@ protected function output() {
'<input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
'<input type="text" value="'.$this->html_safe($this->get('username', 'cypht_user')).'" autocomplete="username" style="display: none;"/>'.
'<label class="screen_reader" for="password">Password</label><input required id="password" '.
'name="password" autocomplete="current-password" class="save_settings_password form-control mb-2" type="password" placeholder="'.$this->trans('Password').'" />'.
'name="password" autocomplete="current-password" class="save_settings_password form-control mb-2 warn_on_paste" type="password" placeholder="'.$this->trans('Password').'" />'.
'<input class="save_settings btn btn-primary me-2" type="submit" name="save_settings_permanently" value="'.$this->trans('Save').'" />'.
'<input class="save_settings btn btn-outline-secondary me-2" type="submit" name="save_settings_permanently_then_logout" value="'.$this->trans('Save and Logout').'" />'.
'</form><form method="post"><input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
Expand Down Expand Up @@ -2159,12 +2159,12 @@ protected function output() {
<span id="srv_setup_stepper_profile_name-error" class="invalid-feedback"></span>
</div>
<div class="form-floating mb-3">
<input required type="text" id="srv_setup_stepper_email" name="srv_setup_stepper_email" class="txt_fld form-control" value="" placeholder="'.$this->trans('Email or Username').'">
<input required type="text" id="srv_setup_stepper_email" name="srv_setup_stepper_email" class="txt_fld form-control warn_on_paste" value="" placeholder="'.$this->trans('Email or Username').'">
<label class="" for="srv_setup_stepper_email">'.$this->trans('Email or Username').'</label>
<span id="srv_setup_stepper_email-error" class="invalid-feedback"></span>
</div>
<div class="form-floating mb-3">
<input required type="password" id="srv_setup_stepper_password" name="srv_setup_stepper_password" class="txt_fld form-control" value="" placeholder="'.$this->trans('Password').'">
<input required type="password" id="srv_setup_stepper_password" name="srv_setup_stepper_password" class="txt_fld form-control warn_on_paste" value="" placeholder="'.$this->trans('Password').'">
<label class="" for="srv_setup_stepper_password">'.$this->trans('Password').'</label>
<span id="srv_setup_stepper_password-error" class="invalid-feedback"></span>
</div>
Expand Down
11 changes: 11 additions & 0 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,10 @@ var imap_smtp_edit_action = function(event) {
}
};

var hasLeadingOrTrailingSpaces = function(str) {
return str !== str.trim();
};

/* create a default message list object */
var Hm_Message_List = new Message_List();

Expand Down Expand Up @@ -2022,6 +2026,13 @@ $(function() {
$('form:not(.search_terms)').areYouSure();
}

$(document).on('paste', '.warn_on_paste', function (e) {
const paste = (e.clipboardData || window.clipboardData).getData('text');
if (hasLeadingOrTrailingSpaces(paste)) {
Hm_Utils.add_sys_message(hm_trans('Pasted text has leading or trailing spaces'), 'danger');
}
});

fixLtrInRtl()
});

Expand Down
2 changes: 1 addition & 1 deletion modules/dynamic_login/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function output() {
$this->trans('Unsaved changes will be lost! Re-enter your password to save and exit.').' &nbsp;'.
'<a href="?page=save">'.$this->trans('More info').'</a></div>'.
'<label class="screen_reader" for="logout_password">'.$this->trans('Password').'</label>'.
'<input id="logout_password" name="password" class="save_settings_password" type="password" placeholder="'.$this->trans('Password').'" />'.
'<input id="logout_password" name="password" class="save_settings_password warn_on_paste" type="password" placeholder="'.$this->trans('Password').'" />'.
'<input class="save_settings" type="submit" name="save_and_logout" value="'.$this->trans('Save and Logout').'" />'.
'<input class="save_settings" id="logout_without_saving" type="submit" name="logout" value="'.$this->trans('Just Logout').'" />'.
'<input class="cancel_logout save_settings" type="button" value="'.$this->trans('Cancel').'" />'.
Expand Down
2 changes: 1 addition & 1 deletion modules/nasa/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function output() {
$res .= 'style="display: none;"';
}
$res .= '><div>Connect to NASA APIs</div>';
$res .= '<div class="col-lg-4 col-sm-12"><input type="text" size="50" class="nasa_api_key form-control" placeholder="'.$this->trans('Enter your API key').'" /><br/>';
$res .= '<div class="col-lg-4 col-sm-12"><input type="text" size="50" class="nasa_api_key form-control warn_on_paste" placeholder="'.$this->trans('Enter your API key').'" /><br/>';
$res .= '<input type="button" class="nasa_api_connect btn btn-secondary" value="'.$this->trans('Connect').'" /></div></div>';
$res .= '<div class="nasa_connect_inner_2" ';
if (!$this->get('nasa_api_key')) {
Expand Down
4 changes: 2 additions & 2 deletions modules/nux/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,12 @@ function credentials_form($details, $mod) {
$res .= '<div class="row"><div class="col col-lg-4">';
// E-mail Address Field
$res .= '<div class="form-floating mb-3 mt-3">';
$res .= '<input type="email" class="form-control" id="nux_email" name="nux_email" placeholder="'.$mod->trans('E-mail Address').'" value="'.$mod->html_safe($details['email']).'">';
$res .= '<input type="email" class="form-control warn_on_paste" id="nux_email" name="nux_email" placeholder="'.$mod->trans('E-mail Address').'" value="'.$mod->html_safe($details['email']).'">';
$res .= '<label for="nux_email">'.$mod->trans('E-mail Address').'</label></div>';

// E-mail Password Field
$res .= '<div class="form-floating mb-3">';
$res .= '<input type="password" class="form-control nux_password" id="nux_password" name="nux_password" placeholder="'.$mod->trans('E-Mail Password').'">';
$res .= '<input type="password" class="form-control nux_password warn_on_paste" id="nux_password" name="nux_password" placeholder="'.$mod->trans('E-Mail Password').'">';
$res .= '<label for="nux_password">'.$mod->trans('E-mail Password').'</label></div>';

// Connect Button
Expand Down
2 changes: 1 addition & 1 deletion modules/pgp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected function output() {
$res .= '<div class="mb-2"><input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />';
$res .= '<label class="form-label" for="public_email">For</label>';
$res .= '<input required id="public_email" name="public_key_email" placeholder="'.$this->trans('E-mail Address');
$res .= '" type="email" class="form-control"></div> <input type="submit" value="'.$this->trans('Import').'" class="btn btn-primary">';
$res .= '" type="email" class="form-control warn_on_paste"></div> <input type="submit" value="'.$this->trans('Import').'" class="btn btn-primary">';
$res .= '</form>';
$res .= '<table class="pgp_keys table mt-3"><thead><tr><th>'.$this->trans('Fingerprint').'</th>';
$res .= '<th>'.$this->trans('E-mail').'</th><th></th></tr>';
Expand Down
Loading