Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by gbr-app-1.alpinelinux.org (Postfix) with ESMTPS id 94D79225B57 for <~alpine/apk-tools@lists.alpinelinux.org>; Tue, 4 Feb 2025 12:30:52 +0000 (UTC) Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-54025432becso5777974e87.1 for <~alpine/apk-tools@lists.alpinelinux.org>; Tue, 04 Feb 2025 04:30:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738672251; x=1739277051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dBId79wGq9+cWAeutg9we2XLG+a9JXEH9I/nUo81Zuk=; b=VSMvsLMNarNrrGSxr8eipWIT4Xkfo8OWmwDlDAvFNI5gO0cAanBe3RjMLJiEUPDMbV SWH5/otRYV8E4e2Xj0CT9QcPp/s6TRpworR/uPGTwSz8mkPQ4cApQ4iy5O41ZCISZgi+ HjsWx8o9Pz39l/mCBwFAgcKuSXqgL/arDF1Vhi53T9zx4YoXQXfB+lN1falj0C4VzFB3 IuBoi9dIngcgH32XD6RJt7tgzn5KZLV19FqD34k2g0hcP1r2paGj1w/BFXgDYeBvup83 /CVfLQEdSt1WnE+tL2adXLHlEtjiX/IIcxUpYvptHojCaliTqDC2lqrRnY/o8D8jgVsS FaeQ== X-Gm-Message-State: AOJu0Ywxlqa4G9YYh7FEidIAcD0TrOPfAVQzF8/UYlaps13qp2/kQ+IM STACt+bSqSBfX+bGdGA+/2PiQevVkqq/U4DC3hOBVAUgjkLKISCH X-Gm-Gg: ASbGnctfSMTU/PLNxbZNOFk22Ml4B6qex+Bt1ZkJ1iJhoYCJjqRT2qSlaDdruu1dtJY gAsdWCkex38fc2d/+NHLubo6G1dnA+gxmJpEDK4iun+B56WysznUhDLUxBomNjtSCHpQCK4Tefv k5fyVAcSZUWxqf9Xfr+WwL0saRUcd1zdtbeadOueAB4TEmU7yGDUXNPdAI3tIy2xZZ7oQ6QeH7o C7tbv2QVBrhXZS+NC8qYh1iHAwFa7rTbrzp1vlibxNMOm7VkknuYTZMsx44P0rBBZ9n/HEMlSkU HIYXVScvq4qOVxyp/pfDJ5DyuQVMgxd+fWCxLVV1uYishDzmJA== X-Google-Smtp-Source: AGHT+IF4ueUUJSEP3A1Kc0cknD3hLAdrjBCI4dLQYfgHrrqdZ125tRyRCr35gyM37BFhUdI9abG04A== X-Received: by 2002:a05:6512:114d:b0:542:6f70:b484 with SMTP id 2adb3069b0e04-543e4be9947mr7429623e87.12.1738672250787; Tue, 04 Feb 2025 04:30:50 -0800 (PST) Received: from onyx.my.domain (88-112-35-58.elisa-laajakaista.fi. [88.112.35.58]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543ebeb0a1fsm1584454e87.144.2025.02.04.04.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2025 04:30:49 -0800 (PST) Date: Tue, 4 Feb 2025 14:30:43 +0200 From: Timo Teras To: John Hallam Cc: ~alpine/apk-tools@lists.alpinelinux.org Subject: Re: [PATCH] libfetch: allow tolerant date parsing Message-ID: <20250204143043.1f37d794@onyx.my.domain> In-Reply-To: References: X-Mailer: Claws Mail 4.3.0 (GTK 3.24.48; x86_64-alpine-linux-musl) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 4 Feb 2025 12:34:56 +0100 John Hallam wrote: > apk's libfetch is strict when interpreting timestamps in > e.g. Last-Modified headers; other tools and web servers (e.g. > Debian's apt-cacher-ng) are lax in generation. I was about to ask why not change apt-cacher-ng instead if they are broken... > The patch below fixes interaction with apt-cacher-ng and allows easy > adding of other obsolete timestamp patterns. ... but went on to read the spec and it says at https://datatracker.ietf.org/doc/html/rfc2616#section-3.3.1 HTTP/1.1 clients and servers that parse the date value MUST accept all three formats (for compatibility with HTTP/1.0), though they MUST only generate the RFC 1123 format for representing HTTP-date values in header fields. So I hope tyou file an issue against apt-cacher-ng to fix their thing. But sounds like libfetch needs fixing too. If going here, it would be good to support all three formats. And have the commit message reflect that these are obsolete formats but required to be support for standards compliance. Would you like to update the patch accordingly, or prefer me to do the additional changes? Timo > > Built and tested with apk-tools 2.14.9. > > Best wishes > > John Hallam > > > --- a/libfetch/http.c > +++ b/libfetch/http.c > @@ -479,11 +479,21 @@ > { > char *locale, *r; > struct tm tm; > + int i; > + /* XXX should add support for date-2 and date-3 */ > + const char *fmts[] ={ "%a, %d %b %Y %H:%M:%S GMT", > + "%a %b %d %H:%M:%S %Y", > + NULL, > + }; > > locale = strdupa(setlocale(LC_TIME, NULL)); > setlocale(LC_TIME, "C"); > - r = strptime(p, "%a, %d %b %Y %H:%M:%S GMT", &tm); > - /* XXX should add support for date-2 and date-3 */ > + i=0; > + while(fmts[i] != NULL) { > + r = strptime(p, fmts[i], &tm); > + if(r != NULL) break; > + i++; > + } > setlocale(LC_TIME, locale); > if (r == NULL) > return (-1);