mirror of
https://github.com/knadh/listmonk.git
synced 2025-02-22 21:35:15 +08:00
fix: trim config before use (#1756)
* feat: ensure hosts are trimmed before saving * feat: trim host before saving bounces
This commit is contained in:
parent
12ab492701
commit
d7b55cd147
2 changed files with 14 additions and 0 deletions
|
@ -108,6 +108,10 @@ func handleUpdateSettings(c echo.Context) error {
|
|||
set.SMTP[i].UUID = uuid.Must(uuid.NewV4()).String()
|
||||
}
|
||||
|
||||
// Ensure the HOST is trimmed of any whitespace.
|
||||
// This is a common mistake when copy-pasting SMTP settings.
|
||||
set.SMTP[i].Host = strings.TrimSpace(s.Host)
|
||||
|
||||
// If there's no password coming in from the frontend, copy the existing
|
||||
// password by matching the UUID.
|
||||
if s.Password == "" {
|
||||
|
@ -134,6 +138,10 @@ func handleUpdateSettings(c echo.Context) error {
|
|||
set.BounceBoxes[i].UUID = uuid.Must(uuid.NewV4()).String()
|
||||
}
|
||||
|
||||
// Ensure the HOST is trimmed of any whitespace.
|
||||
// This is a common mistake when copy-pasting SMTP settings.
|
||||
set.BounceBoxes[i].Host = strings.TrimSpace(s.Host)
|
||||
|
||||
if d, _ := time.ParseDuration(s.ScanInterval); d.Minutes() < 1 {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("settings.bounces.invalidScanInterval"))
|
||||
}
|
||||
|
|
|
@ -112,6 +112,9 @@ export default Vue.extend({
|
|||
// SMTP boxes.
|
||||
let hasDummy = '';
|
||||
for (let i = 0; i < form.smtp.length; i += 1) {
|
||||
// trim the host before saving
|
||||
form.smtp[i].host = form.smtp[i].host?.trim();
|
||||
|
||||
// If it's the dummy UI password placeholder, ignore it.
|
||||
if (this.isDummy(form.smtp[i].password)) {
|
||||
form.smtp[i].password = '';
|
||||
|
@ -128,6 +131,9 @@ export default Vue.extend({
|
|||
|
||||
// Bounces boxes.
|
||||
for (let i = 0; i < form['bounce.mailboxes'].length; i += 1) {
|
||||
// trim the host before saving
|
||||
form['bounce.mailboxes'][i].host = form['bounce.mailboxes'][i].host?.trim();
|
||||
|
||||
// If it's the dummy UI password placeholder, ignore it.
|
||||
if (this.isDummy(form['bounce.mailboxes'][i].password)) {
|
||||
form['bounce.mailboxes'][i].password = '';
|
||||
|
|
Loading…
Reference in a new issue