From 9b4bfec933e84ac5d698ae04f6ce47c088e7cc2c Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 13 Feb 2021 17:49:50 +0100 Subject: [PATCH] Changed regex to basic email regex --- .../controller/VotingController.java | 12 ++---------- src/main/resources/templates/start.html | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java index 98f55b0..f010b21 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -76,16 +76,7 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,24); - LocalDate now = LocalDate.now(); - - if(now.isAfter(finishDate)){ - LOGGER.warn("passed"); - return "errors/votingClosed.html"; - } else { - LOGGER.warn("in Bounds"); return "start.html"; - } } public void sendSimpleMessage(String to, String subject, String text) { @@ -98,7 +89,8 @@ public class VotingController { @RequestMapping("/checkStatus") public String VerifyName(@RequestParam String name, Model model) { - if (name.strip().toLowerCase().matches("[a-z]+\\.[a-z]+@adolfinum+\\.de$")) { + //Basic email regex + if (name.strip().toLowerCase().matches("[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+")) { try { LOGGER.warn(name); Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); diff --git a/src/main/resources/templates/start.html b/src/main/resources/templates/start.html index 98912eb..4cbd6eb 100644 --- a/src/main/resources/templates/start.html +++ b/src/main/resources/templates/start.html @@ -18,7 +18,7 @@ function test() { let input_field = document.getElementById("email_input"); let input = input_field.value; - if (!input.trim().match("[a-z]+\\.[a-z]+@adolfinum+\\.de$")) { + if (!input.trim().match("[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+")) { input_field.value = ""; alert("Die Email-Adresse \"" + input + "\" entspricht nicht den Vorgaben"); }