Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127210 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 qa.php.net (Postfix) with ESMTPS id 4670A1A00BC for ; Sun, 27 Apr 2025 20:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745786921; bh=+wHYCulgFbeqfn5QEUVey6AIkMMEnS/fBnsvL/Gm9bg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=a5D4JyxgHkuWuVNjln4AqiuHl9Jpl1Udt7UADheKEtTUOBTcaCXrqog3Q8lQSZQ2v CKcYhui8/UJHkh+3i5SfL2lhXeFDnu0ysQjM6UKjFaN19LynFU4kSSPSbODLDoTh84 sxu3RjFnhM8cRPI8E5T2+5VWOVMKOhfnCz8Vdg5XGihpa6siBYbYkh/+zM4KVHUaR+ SvyrLAB3Z8XsPUCwr6fo+J9+nSzHdRKH9DQtQGXOt806lbS1v4Nq7eJ0VnqYTFWuY4 3y8xzQq4IfxemEH+Eqe0sSXRNoh1F0WBbdTJ/t70X25zRQiQ45ZxafUPczXcfSfJ2j k+g/FB4D/fePg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC86F180080 for ; Sun, 27 Apr 2025 20:48:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 ; Sun, 27 Apr 2025 20:48:40 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3054ef26da3so3546304a91.3 for ; Sun, 27 Apr 2025 13:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745787057; x=1746391857; 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=IXMgm6OTmtUkP7NzR5Q2BY4nwtQDBh8SywCNzZojeWw=; b=dfB1TRlptFFHis6GbdISqOkdQzl9v9SnAAP+6i3e4NNHhISD9wFS/H7X1wvRhba0GQ oyh8gZhYHAJyAfeQOy4euMVvDSyc9rWnEGn3+eDl/o45+ZT1Pw2al3wWlv1H2KDVpIdc fRccrLvUyBs9lnDfYDTvcOwxMKTpCG6oGiqRzaqRXIW6khzN7BtQVTwx1tgxCU3HzNU6 8+i0ykwKib9au/s13g2y7vI/Y84XYW/ivp1UEbRbWiBBfcvTebdCiQ3ce7nQv7fiS/Vi yZJr/OBHTHLEbep/FekSETSa2nwhtVAH4OPfzovWER7x4V8+6ge8UN98mshG+FhtWRCv 6nQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745787057; x=1746391857; 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=IXMgm6OTmtUkP7NzR5Q2BY4nwtQDBh8SywCNzZojeWw=; b=UMnEMPchiaC1enPnNBlYcyrlYUqYHB8sEDcefyzVsl2nl88NWXi0QvHASVORi6fvol d7oi+9x7jLTzWOAE5Q2QZIAdoUjGrI7GTSZOIU2NvRt6IWvRgQJQFk5p26Z6L7+yqaXj jkEQHD/FPo/7j8V6qxVf8iIvplcV3fF6vJpO7qhRyEzrhQT3/nofRLi6dWekXxQwknyv khAAhTack6Z7xMfpPHDt/VRf6cDMtqPXGZeArLDclJ7X3bAWkovYcT2csMrIwpRe413M mmh6HVEm5a9FSw59deCFM76K0AFweV5t6zpQivljw8h55kxbcM9ISd0aBeE8t4yQOTbu NZLA== X-Forwarded-Encrypted: i=1; AJvYcCVjCCLxoz2oBoxWm8nsJ/f2ilx/XzLc3zW7sHKTjBDZ41kHxGnJ17rDJFZQQyL3HMBMdFUBid4m09s=@lists.php.net X-Gm-Message-State: AOJu0YwLB2gKfpST2mYCLy6iad7sJPwNL+NG/xpcb0eIITa48GsOeqsG UkqRnt/jdD1WXLTR9vG5dVmGQjnf4FZdxMggfjxiv3eNwG2xVp6pY9wkJGszUmWr8gBIgS0aB+k 7T/zs9Lz21050Wc25QBlDiQUgPjc= X-Gm-Gg: ASbGncs9eEsW9gzAE3a4sol/YXegBYzddyyWjWEoAYbYzwPZRtdsdn0MPVjHaIdokvf Jr1s7GcFhsP/JXErzgODyapmmbTzWMIz0EBvHD7UpR7GjF+vCv3DI+dDiRBjTFI3gd0O67KttMg IFLzgibx9wbFL+hb50A+cizdh4MiAntz2aX5nzBRxQBYRtpjoLLEXHXUSD X-Google-Smtp-Source: AGHT+IHhFHf+7auw4juzIGOEOX8CTbvlwECghnEsU6TN0oOx3t4OKtGIKVbkoJQz19/E54vSnMhsiH+RsSv4u55e338= X-Received: by 2002:a17:90b:1807:b0:2ff:6ac2:c5a6 with SMTP id 98e67ed59e1d1-309f8e0b4f7mr11473486a91.31.1745787057134; Sun, 27 Apr 2025 13:50:57 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1BCB4144-231D-45EA-A914-98EE8F0F503A@automattic.com> <8E614C9C-BA85-45D8-9A4E-A30D69981C5D@automattic.com> <8df04e01-deac-404b-beb7-cd982423db63@bastelstu.be> <33427cd03035ef084245c44290b56a55@bastelstu.be> <0aa1eefc3941bdea0092e935074daa58@bastelstu.be> <76d96ea8a78c6025128c0a4b01c94c0a@bastelstu.be> <99d8eacb-1058-44d2-b6e1-314846d59e54@bastelstu.be> In-Reply-To: <99d8eacb-1058-44d2-b6e1-314846d59e54@bastelstu.be> Date: Sun, 27 Apr 2025 22:50:45 +0200 X-Gm-Features: ATxdqUGFZy4FYJvDiEOQByIk0_-1Sfu38WucUXfMJzYpg7PBmo-teH7BTUKFz_k Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= , PHP Internals List Content-Type: multipart/alternative; boundary="00000000000064e0f30633c8b9f7" From: nyamsprod@gmail.com (ignace nyamagana butera) --00000000000064e0f30633c8b9f7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le dim. 27 avr. 2025, 22:32, Tim D=C3=BCsterhus a =C3=A9= crit : > Hi > > On 4/27/25 22:30, ignace nyamagana butera wrote: > > $url =3D Uri\WhatWg\Url::parse("/foo", ".com"); // > > Throws Uri\WhatWg\InvalidUrlException because of $baseUri > > > > Since parse is used shouldn't it return null instead of throwing ? > > In this case the `$baseUri` is invalid. Since this is not expected to be > an untrusted value, it makes sense to me to throw an > `InvalidUrlException` here. The `null` return should only be used for an > invalid `$uri`. > > Best regards > Tim D=C3=BCsterhus > Hi, I understand that but then I fail to see the added value of the parse method vs the default constructor since from the RFC the only difference is that the parse named constructor should instead of throwing return null. If the parse method can still throw from a consumer POV it looses much of it's utility. If I really want that level of knowledge using the constructor should be the only way to go AFAIK. Best regards, Ignace Nyamagana Butera > --00000000000064e0f30633c8b9f7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Le dim. 27 avr. 2025, 22:32, Tim D=C3= =BCsterhus <tim@bastelstu.be> a =C3=A9crit=C2=A0:

Hi

On 4/27/25 22:30, ignace nyamagana butera wrote:
> $url =3D Uri\WhatWg\Url::parse("/foo", ".com");=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//
> Throws Uri\WhatWg\InvalidUrlException because of $baseUri
>
> Since parse is used shouldn't it return null instead of throwing ?=

In this case the `$baseUri` is invalid. Since this is not expected to be an untrusted value, it makes sense to me to throw an
`InvalidUrlException` here. The `null` return should only be used for an invalid `$uri`.

Best regards
Tim D=C3=BCsterhus

=
Hi,

=
I understand that but then I fail to see the added = value of the parse method vs the default constructor since from the RFC the= only difference is that the parse named constructor should instead of thro= wing return null. If the parse method can still throw from a consumer POV i= t looses much of it's utility. If I really want that level of knowledge= using the constructor should be the only way to go AFAIK.

Best regards,
Ign= ace Nyamagana Butera
--00000000000064e0f30633c8b9f7--