225225?>
226226<br>
227227<input id='submitLoginShell' type='submit' value='Set Login Shell' />
228+ <label id='labelSubmitLoginShell'> <!-- value set by JS --> </label>
228229</form>
229230<hr>
230231
@@ -297,14 +298,17 @@ function getNewLoginShell() {
297298 }
298299
299300 function isLoginShellValid(x) {
300- if (x.trim().length === 0) {
301- return false;
301+ if (/^\s|\s$/.test(x)) {
302+ return [false, "must not have leading or trailing whitespace"];
303+ }
304+ if (x.length === 0) {
305+ return [false, "must not be empty"];
302306 }
303307 // only ascii characters allowed
304308 if (!(/^[\x00-\x7F]*$/.test(x))) {
305- return false;
309+ return [ false, "must only contain ASCII characters"] ;
306310 }
307- return true;
311+ return [ true, ""] ;
308312 }
309313
310314 function enableOrDisableCustomLoginBoxHighlight() {
@@ -323,18 +327,21 @@ function enableOrDisableCustomLoginBoxHighlight() {
323327
324328 function enableOrDisableSubmitLoginShell() {
325329 var newLoginShell = getNewLoginShell();
326- if (!isLoginShellValid(newLoginShell)) {
330+ isValidArr = isLoginShellValid(newLoginShell);
331+ isValid = isValidArr[0];
332+ isValidReason = isValidArr[1];
333+ if (!isValid) {
327334 $("#submitLoginShell").prop("disabled", true);
328- $("#submitLoginShell ").prop("title", "Invalid Login Shell" );
335+ $("#labelSubmitLoginShell ").text(`(invalid login shell: ${isValidReason})` );
329336 return;
330337 }
331338 if (newLoginShell == ldapLoginShell) {
332339 $("#submitLoginShell").prop("disabled", true);
333- $("#submitLoginShell ").prop("title", "Login Shell Unchanged ");
340+ $("#labelSubmitLoginShell ").text("(no change) ");
334341 return;
335342 }
336343 $("#submitLoginShell").prop("disabled", false);
337- $("#submitLoginShell ").prop("title", "Submit Login Shell ");
344+ $("#labelSubmitLoginShell ").text(" ");
338345 }
339346 $("#customLoginBox").on("input", enableOrDisableSubmitLoginShell);
340347 $("#loginSelector").change(enableOrDisableSubmitLoginShell);
0 commit comments