]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
UJ-2: Added invalid dates + tests
authorcesarvh <cesarv.h@berkeley.edu>
Wed, 17 Oct 2018 02:52:13 +0000 (19:52 -0700)
committercesarvh <cesarv.h@berkeley.edu>
Tue, 19 Mar 2019 19:37:04 +0000 (12:37 -0700)
services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/antlr/ANTLRStructuredDateEvaluator.java
services/structureddate/structureddate/src/test/resources/test-dates.yaml

index 654c2fbb7335afe2a195c038f5e032b85ffe94d2..fcd7da8be6e3e38b0388a889f36d93aa512b976c 100644 (file)
@@ -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
+}
index 6ca1d78874582b57b3e0455f2298b27456b1106b..2e19c9f9993f41764ab7be86294015fb2122e368 100644 (file)
 
   '3/4?/2005':                           # question mark
                                          null
+
+  '100 June 2010': 
+                                          null
+
+  '13 June 0': 
+                                          null
+                                          
\ No newline at end of file