From 02d026a28f7488da694c1bd6c2ddb588c80d49e5 Mon Sep 17 00:00:00 2001
From: Nick Liu <deltik@gmx.com>
Date: Wed, 24 Jan 2018 04:40:09 -0600
Subject: [PATCH] Improvements to Preferences SMTP form validation

SMTP server max string length increased from 50 to 128
SMTP username max string length increased from 50 to 128
SMTP password max string length increased from 50 to 128

SMTP password is actually optional now, as intended

SMTP password now accepts spaces

SMTP password needs to be at least 4 characters long

Autocomplete disabled for Firefox 38+, Chrome 34+, and Internet Explorer 11+

Fixes: #3003
---
 e107_handlers/mailout_admin_class.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php
index 208a3b968..945f8d168 100644
--- a/e107_handlers/mailout_admin_class.php
+++ b/e107_handlers/mailout_admin_class.php
@@ -2141,17 +2141,17 @@ class mailoutAdminClass extends e107MailManager
 		$text .= "
 		<tr>
 		<td>".LAN_MAILOUT_87.":&nbsp;&nbsp;</td>
-		<td>".$frm->text('smtp_server',$pref['smtp_server'], 50, array('size'=>'xxlarge'))."</td>
+		<td>".$frm->text('smtp_server',$pref['smtp_server'], 128, array('size'=>'xxlarge'))."</td>
 		</tr>
 
 		<tr>
 		<td>".LAN_MAILOUT_88.":</td>
-		<td style='width:50%;' >".$frm->text('smtp_username',$pref['smtp_username'], 50, array('size'=>'xxlarge', 'placeholder'=>"(".LAN_OPTIONAL.")"))."</td>
+		<td style='width:50%;' >".$frm->text('smtp_username',$pref['smtp_username'], 128, array('size'=>'xxlarge', 'placeholder'=>"(".LAN_OPTIONAL.")"))."</td>
 		</tr>
 
 		<tr>
 		<td>".LAN_MAILOUT_89.":</td>
-		<td>".$frm->password('smtp_password',$pref['smtp_password'], 50, array('size'=>'xxlarge', 'placeholder'=>"(".LAN_OPTIONAL.")"))."
+		<td>".$frm->password('smtp_password',$pref['smtp_password'], 128, array('size'=>'xxlarge', 'required'=>false, 'pattern'=>'.{4,}', 'placeholder'=>"(".LAN_OPTIONAL.")", 'autocomplete'=>'new-password'))."
 		</td>
 		</tr>