This is an automated email from the ASF dual-hosted git repository.
thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
The following commit(s) were added to refs/heads/master by this push:
new 3c8d61038 Tweaking ContentType's parser regular expression.
3c8d61038 is described below
commit 3c8d6103832eec3bc06029dd2532f06df717431f
Author: Thiago H. de Paula Figueiredo <[email protected]>
AuthorDate: Sun Apr 17 23:50:16 2022 -0300
Tweaking ContentType's parser regular expression.
---
.../src/test/java/org/apache/tapestry5/root/ContentTypeTest.java | 7 +++++++
.../src/main/java/org/apache/tapestry5/http/ContentType.java | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git
a/tapestry-core/src/test/java/org/apache/tapestry5/root/ContentTypeTest.java
b/tapestry-core/src/test/java/org/apache/tapestry5/root/ContentTypeTest.java
index 5be6bda94..00842acad 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/root/ContentTypeTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/root/ContentTypeTest.java
@@ -154,4 +154,11 @@ public class ContentTypeTest extends TestBase
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=:;");
+ }
+
}
diff --git
a/tapestry-http/src/main/java/org/apache/tapestry5/http/ContentType.java
b/tapestry-http/src/main/java/org/apache/tapestry5/http/ContentType.java
index bf5da4a24..bf1b75cf8 100644
--- a/tapestry-http/src/main/java/org/apache/tapestry5/http/ContentType.java
+++ b/tapestry-http/src/main/java/org/apache/tapestry5/http/ContentType.java
@@ -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)*