Skip to content

Commit

Permalink
Tweaking ContentType's parser regular expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohp committed Apr 18, 2022
1 parent 372df09 commit 3c8d610
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -154,4 +154,11 @@ public void add_charset() throws Exception
assertEquals(base.toString(), "text/html");
assertEquals(charset.toString(), "text/html;charset=utf-8");
}

@Test(timeOut = 100, expectedExceptions = IllegalArgumentException.class)
public void constructor_timeout() throws Exception
{
new ContentType("a/a;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;a=:;");
}

}
Expand Up @@ -39,7 +39,7 @@ public final class ContentType

private final Map<String, String> parameters;

private static final Pattern PATTERN = Pattern.compile("^(.+)/([^;]+)(;(.+=[^;]+))*$");
private static final Pattern PATTERN = Pattern.compile("^(.+)/([^;]+)(;(.+=[^;]+)){0,5}$");

/**
* Creates a new content type from the argument. The format of the argument has to be basetype/subtype(;key=value)*
Expand Down

0 comments on commit 3c8d610

Please sign in to comment.