|
25 | 25 | #include "absl/status/statusor.h" |
26 | 26 | #include "absl/strings/str_cat.h" |
27 | 27 | #include "absl/strings/string_view.h" |
| 28 | +#include "absl/time/time.h" |
28 | 29 | #include "common/any.h" |
29 | 30 | #include "common/value.h" |
30 | 31 | #include "common/value_kind.h" |
31 | 32 | #include "extensions/protobuf/value.h" |
32 | 33 | #include "internal/proto_time_encoding.h" |
33 | 34 | #include "internal/status_macros.h" |
| 35 | +#include "internal/time.h" |
34 | 36 | #include "google/protobuf/arena.h" |
35 | 37 | #include "google/protobuf/descriptor.h" |
36 | 38 | #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
@@ -84,14 +86,18 @@ absl::StatusOr<Value> FromObject( |
84 | 86 | if (!any.UnpackTo(&duration)) { |
85 | 87 | return absl::InvalidArgumentError("invalid duration"); |
86 | 88 | } |
87 | | - return cel::DurationValue(internal::DecodeDuration(duration)); |
| 89 | + absl::Duration d = internal::DecodeDuration(duration); |
| 90 | + CEL_RETURN_IF_ERROR(cel::internal::ValidateDuration(d)); |
| 91 | + return cel::DurationValue(d); |
88 | 92 | } else if (any.type_url() == |
89 | 93 | "type.googleapis.com/google.protobuf.Timestamp") { |
90 | 94 | google::protobuf::Timestamp timestamp; |
91 | 95 | if (!any.UnpackTo(×tamp)) { |
92 | 96 | return absl::InvalidArgumentError("invalid timestamp"); |
93 | 97 | } |
94 | | - return cel::TimestampValue(internal::DecodeTime(timestamp)); |
| 98 | + absl::Time time = internal::DecodeTime(timestamp); |
| 99 | + CEL_RETURN_IF_ERROR(cel::internal::ValidateTimestamp(time)); |
| 100 | + return cel::TimestampValue(time); |
95 | 101 | } |
96 | 102 |
|
97 | 103 | return extensions::ProtoMessageToValue(any, descriptor_pool, message_factory, |
|
0 commit comments