diff --git a/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java b/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java index 3c7099f45f..91b1954221 100644 --- a/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java +++ b/extensions/guacamole-auth-restrict/src/main/java/org/apache/guacamole/calendar/TimeRestrictionParser.java @@ -49,7 +49,7 @@ public class TimeRestrictionParser { * */ private static final Pattern RESTRICTION_REGEX = - Pattern.compile("(?:^|;)+([1-7*])(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\\-((?:[01][0-9]|2[0-3])[0-5][0-9]))+"); + Pattern.compile("(?:^|;)+([0-7*])(?::((?:[01][0-9]|2[0-3])[0-5][0-9])\\-((?:[01][0-9]|2[0-3])[0-5][0-9]))+"); /** * The RegEx group that contains the start day-of-week of the restriction. @@ -136,7 +136,14 @@ public static List parseString(String restrictionString) { // A specific day of the week. default: - restrictions.add(new DailyRestriction(DayOfWeek.of(Integer.parseInt(dayString)), startTime, endTime)); + int dayInt = Integer.parseInt(dayString); + + // While JavaScript sees Sunday as "0" and "7", DayOfWeek + // does not, so we'll convert it to "7" in order to process it. + if (dayInt == 0) + dayInt = 7; + + restrictions.add(new DailyRestriction(DayOfWeek.of(dayInt), startTime, endTime)); } diff --git a/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js b/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js index 86312aae6f..de83b6a93c 100644 --- a/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js +++ b/extensions/guacamole-auth-restrict/src/main/resources/controllers/timeRestrictionFieldController.js @@ -58,7 +58,6 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s * twice - once for the 0-index and once for the 7 index. */ $scope.weekDays = [ - { id : '0', day : 'Sunday' }, { id : '1', day : 'Monday' }, { id : '2', day : 'Tuesday' }, { id : '3', day : 'Wednesday' }, @@ -132,8 +131,16 @@ angular.module('guacRestrict').controller('timeRestrictionFieldController', ['$s if (restrictionRegex.test(restrArray[i])) { var currArray = restrArray[i].match(restrictionRegex); let entry = new TimeRestrictionEntry(); - entry.startTime = new Date(Date.UTC(templateDate.getFullYear(), templateDate.getMonth(), templateDate.getDate(), parseInt(currArray[2].slice(0,2)), parseInt(currArray[2].slice(2)))); - entry.endTime = new Date(Date.UTC(templateDate.getFullYear(), templateDate.getMonth(), templateDate.getDate(), parseInt(currArray[3].slice(0,2)), parseInt(currArray[3].slice(2)))); + entry.startTime = new Date(Date.UTC(templateDate.getFullYear(), + templateDate.getMonth(), + templateDate.getDate(), + parseInt(currArray[2].slice(0,2)), + parseInt(currArray[2].slice(2)))); + entry.endTime = new Date(Date.UTC(templateDate.getFullYear(), + templateDate.getMonth(), + templateDate.getDate(), + parseInt(currArray[3].slice(0,2)), + parseInt(currArray[3].slice(2)))); var origDay = currArray[1]; if (currArray[1] === '*')