diff --git a/src/lib/config/module_spec.cc b/src/lib/config/module_spec.cc index eed6b72430d184b6a57d04c9371349efb31e8fcc..27cf9939056da23a3857b3bedad3d5a322cf8d43 100644 --- a/src/lib/config/module_spec.cc +++ b/src/lib/config/module_spec.cc @@ -103,8 +103,15 @@ check_format(ConstElementPtr value, ConstElementPtr format_name) { BOOST_FOREACH (const format_types::value_type& f, time_formats) { if (format_name->stringValue() == f.first) { struct tm tm; + char buf[255] = ""; + memset(&tm, 0, sizeof(tm)); + // reverse check return (strptime(value->stringValue().c_str(), - f.second.c_str(), &tm) != NULL); + f.second.c_str(), &tm) != NULL + && strftime(buf, sizeof(buf), + f.second.c_str(), &tm) != 0 + && strcmp(value->stringValue().c_str(), + buf) == 0); } } return (false); diff --git a/src/lib/config/tests/module_spec_unittests.cc b/src/lib/config/tests/module_spec_unittests.cc index 315a78df06855b25bbd3ebd57c277201a62aa8fc..cfd0ff5216f82cb07f2f083fc906c26051dc544e 100644 --- a/src/lib/config/tests/module_spec_unittests.cc +++ b/src/lib/config/tests/module_spec_unittests.cc @@ -287,7 +287,7 @@ TEST(ModuleSpec, CheckFormat) { item_default = "\"item_default\": \"2011-05-27\","; item_format = "\"item_format\": \"date\""; specs.push_back("," + item_default + item_format); - item_default = "\"item_default\": \"19:42:57Z\","; + item_default = "\"item_default\": \"19:42:57\","; item_format = "\"item_format\": \"time\""; specs.push_back("," + item_default + item_format); diff --git a/src/lib/python/isc/config/module_spec.py b/src/lib/python/isc/config/module_spec.py index d1200800943bc3d19e436717ad0d19d7a3682fd7..b79f9282372ecbabac8b9d8c36cb15c896c6ed3b 100644 --- a/src/lib/python/isc/config/module_spec.py +++ b/src/lib/python/isc/config/module_spec.py @@ -330,8 +330,10 @@ def _check_format(value, format_name): for fmt in time_formats: if format_name == fmt: try: - time.strptime(value, time_formats[fmt]) - return True + # reverse check + return value == time.strftime( + time_formats[fmt], + time.strptime(value, time_formats[fmt])) except (ValueError, TypeError): break return False