Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127213 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 982171A00BC for ; Sun, 27 Apr 2025 21:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745787803; bh=usJxnX88Gvx9SXqOzXxzrx5pVp38cXU3BlSbCQ3gHKQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QeD7iZUUafpeufjofsjCz1ffN8qM3yCdY2q73FH4+8TCXtMWXi4zy1XUcI1kuS0Jf 4dKl34IfTm9cPrYbbphc8k/ViZ0QZ1LdmD+IZpFbSc+l/qlQizMznF0Rr2oCgTTbnU WQ/1Xz1XLcn/wKX+wyNZEpHI9r/F/NI5VdC1orUBhK5SLGGT0jYe4fv4ERIwE5pnhM kyer4al/7YfuKbPYBWd9TaKI8Mm6mtU45o/LsKCzN1d2SDiwGNbKwGxBMym0ufeY+j lhHDxEW6I22pnl8jNRlSJY7hPBfvhlZo+B+H/XOhT5JIAMddDjgio/hZHRtWkgw20W nY821Ehxcs24g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5BE851801E4 for ; Sun, 27 Apr 2025 21:03:23 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 21:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1745787939; bh=M4Bz2+m9a+Q+hOF/hbYbmCKhewkd5B5VuXV3hxIIwSU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=Nh1+2OOBcIGL2XzylOIjX1onvwGyOJryvBh2+pbsRGIP12TF/pcIB7zZbNOGYzaat l4meMGmOobqOzpVg2B8gqyZ/ryLY9Q7dGPkB6bJVoVWPyZw0FcC2bNCcZYNFNtoPAS JPPlm+r3VnBwpCpqtSxgrTLEZCUjaxVGn86ratiYnfWk3KgZfVoGVXbSxOVB3xrsVs /z1J8udu4Wu3qCqi2uCZA/x1g1tt07avg198jLHPa4Z36zTE9WmqfSOV73DHFtwu/9 v32PkelnyXNcWkGgRbakghnhrld7S8KOYGbkk57Pn3s0qhP80pz9any2w3y1jbSZU6 RkqO36wUhkOyw== Message-ID: Date: Sun, 27 Apr 2025 23:05:37 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API To: ignace nyamagana butera Cc: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= , PHP Internals List 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> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/27/25 22:50, ignace nyamagana butera wrote: > 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. Since the `$baseUri` is a known existing URI, I expect it to be always be valid, otherwise it would be a programming error. The (relative) $uri is the bit that comes from an untrusted source. Handling both cases by returning `null` would make the API much worse, since it is no longer clear which of the values is invalid. Perhaps as a solution, it would make sense to change the signature to: (string $uri, ?self $baseUri = null) instead to enforce that the $baseUri must be valid. This might also improve performance, by allowing to avoid repeatedly parsing the $baseUri, e.g. when bulk processing a number of relative links. Best regards Tim Düsterhus