From: cesarvh Date: Wed, 17 Oct 2018 02:52:13 +0000 (-0700) Subject: UJ-2: Added invalid dates + tests X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=9f8be365d34b287774053a2785d1843a96c25d82;p=tmp%2Fjakarta-migration.git UJ-2: Added invalid dates + tests --- diff --git a/services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java b/services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java index 654c2fbb7..fcd7da8be 100644 --- a/services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java +++ b/services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java @@ -489,10 +489,18 @@ public class ANTLRStructuredDateEvaluator extends StructuredDateBaseListener imp year = num1; } + stack.push(year); stack.push(numMonth); stack.push(dayOfMonth); stack.push(era); + + if (dayOfMonth > 31 || dayOfMonth <= 0) { + throw new StructuredDateFormatException("unexpected day of month '" + Integer.toString(dayOfMonth) + "'"); + } + if (year == 0) { + throw new StructuredDateFormatException("unexpected year '" + Integer.toString(year) + "'"); + } } @Override @@ -1140,4 +1148,4 @@ public class ANTLRStructuredDateEvaluator extends StructuredDateBaseListener imp } } } -} \ No newline at end of file +} diff --git a/services/structureddate/structureddate/src/test/resources/test-dates.yaml b/services/structureddate/structureddate/src/test/resources/test-dates.yaml index 6ca1d7887..2e19c9f99 100644 --- a/services/structureddate/structureddate/src/test/resources/test-dates.yaml +++ b/services/structureddate/structureddate/src/test/resources/test-dates.yaml @@ -1157,3 +1157,10 @@ '3/4?/2005': # question mark null + + '100 June 2010': + null + + '13 June 0': + null + \ No newline at end of file