bounswe / bounswe2015group7

Sculture, The Software Project of Future
6 stars 4 forks source link

Bug on email syntax checking function #174

Closed fthdgn closed 8 years ago

fthdgn commented 8 years ago
   public static boolean isValidEmail(String enteredEmail) {
        String EMAIL_REGIX = "^[\\\\w!#$%&’*+/=?`{|}~^-]+(?:\\\\.[\\\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\\\.)+[a-zA-Z]{2,6}$";
        Pattern pattern = Pattern.compile(EMAIL_REGIX);
        Matcher matcher = pattern.matcher(enteredEmail);
        return ((!enteredEmail.isEmpty()) && (enteredEmail != null) && (matcher.matches()));
    }

    public static boolean checkEmailSyntax(String email) {
        if (email == null || email.isEmpty() || isValidEmail(email))
            return false;
        return true;
    }

The regex does not catching email addresses. It always return false, whether the email address valid or not valid. The controller uses checkEmailSyntax, and it uses inverse of isValidEmail. The controller accepts all strings.

bilalyasar commented 8 years ago

closed via https://github.com/bounswe/bounswe2015group7/commit/7e4eac3fc848ba4a2a932d88e0c1ce3e170e8363