This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git
The following commit(s) were added to refs/heads/master by this push:
new 0ef21683 MIME4J-325 DateTimeParser should throw ParseException if
value can't be parsed (#88)
0ef21683 is described below
commit 0ef216839687e1b0b027f2cff75912f4432747a1
Author: Wojtek <[email protected]>
AuthorDate: Fri Jun 30 02:08:28 2023 -0400
MIME4J-325 DateTimeParser should throw ParseException if value can't be
parsed (#88)
---
.../james/mime4j/field/datetime/DateTimeParser.jj | 20 ++++++++++++++++++--
.../james/mime4j/field/datetime/DateTimeTest.java | 5 +++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git
a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
index 8582f6e9..f67cf312 100644
---
a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
+++
b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
@@ -72,6 +72,22 @@ public class DateTimeParser {
}
}
+ public DateTime parseAll() throws ParseException {
+ try {
+ return doParseAll();
+ } catch (TokenMgrError e) {
+ throw new ParseException(e);
+ }
+ }
+
+ public DateTime parseLine() throws ParseException {
+ try {
+ return doParseLine();
+ } catch (TokenMgrError e) {
+ throw new ParseException(e);
+ }
+ }
+
private static int parseDigits(Token token) {
return Integer.parseInt(token.image, 10);
}
@@ -152,14 +168,14 @@ public class DateTimeParser {
PARSER_END(DateTimeParser)
-DateTime parseLine() :
+private DateTime doParseLine() :
{DateTime dt;}
{
dt=date_time() ["\r"] "\n"
{ return dt; }
}
-DateTime parseAll() :
+private DateTime doParseAll() :
{DateTime dt;}
{
dt=date_time() <EOF>
diff --git
a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
index 02510bae..542021f0 100644
--- a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
@@ -101,6 +101,11 @@ public class DateTimeTest {
});
}
+ @Test(expected=ParseException.class)
+ public void testParseInvalidDateTime() throws Exception {
+ new DateTimeParser(new StringReader("Thu, 29 Jan
\u008Crodkowoeuropejski czas stand.")).parseAll();
+ }
+
private void ensureAllEqual(String[] dateStrings) throws ParseException {
for (int i = 0; i < dateStrings.length - 1; i++) {
long date1 = new DateTimeParser(new
StringReader(dateStrings[i])).parseAll().getDate().getTime();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]