Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128043 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 91B411A00BC for ; Mon, 14 Jul 2025 21:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752528304; bh=tVlWXEPoYK1LJ7JA6M7rpK7J40bERK4yDZpeZMUX0Bw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SM9rIAdKhGp94kUTwUgtOZyI0XUW1Vvfw5C3cRhvz2R5FgFSEArg0tl5PLjc9ccL0 LM8YPXsN4Yd94YHDDAmEii5gzfAl5KeSQjpp00h6HGmT6sCetzGsiju+CmTVUAVBlB 0jdTbjrzm2y/ekW5Ybom1jbuSWIIqN52ERfOGP+t/PFijWXXl7+vAQJmzi+SzgMrw1 Ms4K/0c5wh5KSkXLbVqc4e+EDMtV9Mkx+tmlHzNFgOjCVQ29wz628cOL4IZJAWAVkR WKNX/6BT4fXO7dvSJMtZR3Foks2CCvH3WWwSislVmxA7Ti+gvEFh/lbKpz7DLmcOP4 2/GmdsdlaXVlA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 782C4180050 for ; Mon, 14 Jul 2025 21:25:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 14 Jul 2025 21:25:01 +0000 (UTC) Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-531a1fad7faso2267314e0c.2 for ; Mon, 14 Jul 2025 14:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; t=1752528408; x=1753133208; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tVlWXEPoYK1LJ7JA6M7rpK7J40bERK4yDZpeZMUX0Bw=; b=F1DeI50p7ho8R7NMGJeXxWckWsLSaO0xOqr/ABNhGMwsUcWcr2rOoi40hJA8YlHMy/ GFbCbv7KZIT7W0lENJ+IXZ2TC8t0Z9JIpHJaytySvFfTPbYxzyIaDmLonKmc6yIh1Trb 64EB5U1wnA5EQVOukwNDCKYSmW2s5OGcqShqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752528408; x=1753133208; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tVlWXEPoYK1LJ7JA6M7rpK7J40bERK4yDZpeZMUX0Bw=; b=Q/7dQFKVpv0aRb/alUWdhkf7KhfT15bl3cmgRaRHBwCqsLjBBRV1qGhc/i03MzL1ai uuq1HD83FeICFyVHmNvB1Q9Dcjqs4EEONB1ivofscC5xEhswkpxA+6ldRn3fqjLYEd1x +HrnKiIQn7Z5c4d7ucaLTdIM78y3SAIVd5LwcF9RxETyeNbcTHrYzUi0jo7mXxtRLfRV /OesX6cfDvPPI0kODoNrK2xwAoNV6/9tR3Czqr5sYlt/FL0QMi+btyyBpp4aQJEr+hhx I9A3qMSKCyr0vudTxt+JGgVltS5wZdP8ogPfczZ9cQ5p5f9AjSrjKY9RcOR6OaOfbHEM nMXA== X-Gm-Message-State: AOJu0YzFwApX5nEU1vUfZPox7I8AfqTll1UfcTTsmeJpSPjt4M7f1hn+ VKBUmWyXGcbH1Lh9OMHQ2G9dpkDU0W+ck1lAEkOTWdfUIFtgnkZT0NGngCUcDUchidVwslBIhQI o6KoW79ErbZCKZiwlkElPXEyJPM5GxBw5WF1EjfYK X-Gm-Gg: ASbGnct/1m9igOtWrzGdgz0+xIqYYLLce2kQf6Ujeexeo20VjSknVWpbjWqYspL8Ifi Qxeh+J6yfyQDCjeFguyCIkdv9uNFEe9YjS+777D6iJ3oVwFT6h28HRXkOVUtAJsOXZk3aWicj2t lnL4CsfWy88CxB19W4FW0x31GEESc8ebtG3/Jz2asf+JknfoYkeAZIdcqDFAR50hHBci9OF+2Pj nVR1ok= X-Google-Smtp-Source: AGHT+IELxuQAjrTLdxQnvCwaTMp/ST+hr6uvXSnIpPRkTqZNo5kB05aC07nwMoiK9fLm4aCJtC+FjH0hHy3sfNm28dU= X-Received: by 2002:a05:6102:b0d:b0:4e7:db33:5980 with SMTP id ada2fe7eead31-4f6411b435cmr9773168137.11.1752528408315; Mon, 14 Jul 2025 14:26:48 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <348856E5-6A4E-455A-81AE-882832170168@rwec.co.uk> <38e57171-fc2e-4d79-8614-0b1c5a2efc72@app.fastmail.com> In-Reply-To: Date: Tue, 15 Jul 2025 00:26:36 +0300 X-Gm-Features: Ac12FXzDI7aEb3-EJpT7kmjljkUPKriDxayfJSo-LE-ph-MgvbIwMJUqGdg3XCM Message-ID: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Add RFC 4648 compliant data encoding API To: ignace nyamagana butera Cc: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000003c9c040639ea5144" From: narf@devilix.net (Andrey Andreev) --0000000000003c9c040639ea5144 Content-Type: text/plain; charset="UTF-8" Hi all, I have a few suggestions, starting with naming improvements: - Forgiving instead of Lenient (align with https://infra.spec.whatwg.org/#forgiving-base64) - Shorten the option names; one example would be Variable/Constant instead of Unprotected/ConstantTime, but I think most could be rethinked - $input or $data instead of $decoded (could actually do the same instead of $encoded, but that one doesn't feel as wrong) - Not strictly about naming, but it similarly feels wrong that UnableToDecodeException extends EncodingException (which seems to have no purpose) However, I'm not a fan of how these simple functions have so many option flags ... it feels forced, trying to accomodate too much at once. I'd rather have discrete functions, like base64_*() and base64url_*() - I chose this example because base64 and base64url also have arguably different desirable defaults for padding; almost all pad-stripping I've seen in the wild has been for the purposes of converting to base64url. On a semi-related note, I'm not sure if including the IMAP variant isn't complicating things for no good reason (it is extra-niche, and we have imap_binary/base64() already). Also, the RFC doesn't specify whether DecodingMode::Strict would cause an error in case of missing padding? That being said, I'm very glad to see this! Cheers, Andrey. --0000000000003c9c040639ea5144 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

I have a few suggest= ions, starting with naming improvements:
- Forgiving i= nstead of Lenient (align with https://infra.spec.whatwg.org/#forgiving-base64)
- Shorten the option names; one example would be Variable/Constant inste= ad of Unprotected/ConstantTime, but I think most could be rethinked
- $input or $data instead of $decoded (could actually do the same instea= d of $encoded, but that one doesn't feel as wrong)
- Not stri= ctly about naming, but it similarly feels wrong that=20 UnableToDecodeException extends EncodingException (which seems to have=20 no purpose)

However, I'm not a fan of how thes= e simple functions have so many option flags ... it feels forced, trying to= accomodate too much at once. I'd rather have discrete functions, like = base64_*() and base64url_*() - I chose this example because base64 and base= 64url also have arguably different desirable defaults for padding; almost a= ll pad-stripping I've seen in the wild has been for the purposes of con= verting to base64url.
On a semi-related note, I'm not sure if= including the IMAP variant isn't complicating things for no good reason (it is extra-niche, and we have=20 imap_binary/base64() already).

Also, the RFC doesn= 't specify whether DecodingMode::Strict would cause an error in case of= missing padding?

That being said, I'm very gl= ad to see this!

Cheers,
Andrey.
--0000000000003c9c040639ea5144--