From f25d7dbaa85dd9b3aa1cd649678bdf843e95a7c9 Mon Sep 17 00:00:00 2001 From: William Vu Date: Fri, 16 Nov 2018 11:48:44 -0600 Subject: [PATCH] Revert Date.parse check for DisclosureDate An approximation of https://en.wikipedia.org/wiki/Robustness_principle. --- tools/dev/msftidy.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/dev/msftidy.rb b/tools/dev/msftidy.rb index 5f34c9cc27..016d9a75bd 100755 --- a/tools/dev/msftidy.rb +++ b/tools/dev/msftidy.rb @@ -441,10 +441,18 @@ class Msftidy # Check disclosure date format if @source =~ /["']DisclosureDate["'].*\=\>[\x0d\x20]*['\"](.+?)['\"]/ - begin - Date.parse($1) #Captured date + d = $1 #Captured date # Flag if overall format is wrong - rescue ArgumentError + if d =~ /^... (?:\d{1,2},? )?\d{4}$/ + # Flag if month format is wrong + m = d.split[0] + months = [ + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' + ] + + error('Incorrect disclosure month format') if months.index(m).nil? + else error('Incorrect disclosure date format') end else