Allow parsing either RFC9557 timestamps (which wants explicit +00:00) or
authorsthen <sthen@openbsd.org>
Tue, 30 Apr 2024 14:26:50 +0000 (14:26 +0000)
committersthen <sthen@openbsd.org>
Tue, 30 Apr 2024 14:26:50 +0000 (14:26 +0000)
the existing format (with Z). From espie.

usr.sbin/pkg_add/OpenBSD/PackingElement.pm

index 6a3387e..e0110c0 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.290 2023/11/22 11:18:37 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.291 2024/04/30 14:26:50 sthen Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -1957,7 +1957,9 @@ sub iso8601($self)
 
 sub _iso8601_to_time($s)
 {
-       if ($s =~ m/^(\d{4})\-(\d{2})\-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})Z$/) {
+       # XXX RFC 9557 explicitly wants +00:00 instead of Z for UTC,
+       # so recognize both
+       if ($s =~ m/^(\d{4})\-(\d{2})\-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(?:Z|\+00\:00)$/) {
                my ($year, $month, $day, $hour, $min, $sec) =
                    ($1 - 1900, $2-1, $3, $4, $5, $6);
                require POSIX;