Skip to content

Commit

Permalink
Merge pull request #26 from MOderkerk/development
Browse files Browse the repository at this point in the history
Automated PR
  • Loading branch information
MOderkerk committed Feb 9, 2022
2 parents f0f75e9 + 72c8f74 commit 42828e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private IllegalCharacterIdentification() {
private static final String REGEX_DOMAIN = "\\b[|']";
private static final String REGEX_SPECIAL_START = "^[!\"§$%&\\/()=?`#~+*\\[\\]]";
private static final String REGEX_SPECIAL_END = "[!\"§$%&\\/()=?`#~+*\\[\\]]$";

/**
* Check the given String gainst the given rule
*
Expand All @@ -62,11 +62,18 @@ public static void checkString(String input, CheckRuleEnum rule) {
Matcher matcher = pattern.matcher(input);
if (matcher.find()) throw new IllegalArgumentException(ILLEGAL_CHARACTERS_FOUND);


if (rule != CheckRuleEnum.RECIPIENT) {
pattern = Pattern.compile(REGEX_SPECIAL_START, Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(input);
if (matcher.find()) throw new IllegalArgumentException(ILLEGAL_CHARACTERS_FOUND);
}
else
{
pattern = Pattern.compile(REGEX_SPECIAL_START, Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(input.substring(0,1));
if (matcher.find()) throw new IllegalArgumentException(ILLEGAL_CHARACTERS_FOUND);
}
if (rule.equals(CheckRuleEnum.TLD)) {
pattern = Pattern.compile(REGEX_SPECIAL_END, Pattern.CASE_INSENSITIVE);
matcher = pattern.matcher(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class RestITTest {
@ParameterizedTest
@CsvSource({
"test@oderkerk.de",
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org",
"#%&*+/=^{}~@iana.org"
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org"
})
void testRestControllerOK(String testcase) throws IOException, URISyntaxException {

Expand Down

0 comments on commit 42828e0

Please sign in to comment.