Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124001 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 70E4A1A009C for ; Fri, 28 Jun 2024 21:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719610698; bh=JqlAbPZLRZdJohBUDhs1Erg0B0Z1Rseih7x/JjLLVIM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=YbNfgUydZf+37SzlN4ZTSLFiZz/FnmKW1s8EpkXviYK14k16AlFjz16QFUyUc70mN wN1z5ei0Y3VpMDNroJeZ0CPurFL7ev8pS8jYfWyWZaRO1qorD+4H6dFs7w/1C1EcJc S8jxeeHKwGa6fM0Y01qn/VbNashiNoZpEq6rv7yP2Yjp30xnyttWEN9xQNf7J0n9MB B5QG9dijRCTKpJHCPpXg8BoiMhxJ0GBOpt2M+BsvPpT0Orz31dRfUKvdFbJEz14fJF CZRBa0vQzZ2vS8PUeiZsSlFHdMhIqzCEv8CKZ2UYchdt+a2UO45OboBAuk5uQcGuwT FzB+a/06MeP0w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 86416180752 for ; Fri, 28 Jun 2024 21:38:17 +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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 ; Fri, 28 Jun 2024 21:38:17 +0000 (UTC) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4256788e13bso8115475e9.2 for ; Fri, 28 Jun 2024 14:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719610617; x=1720215417; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=zdLWS2vCtwF4XqHOD2o3vypJvE6S4oRWVuw0s9SQRcQ=; b=cy5LJBAVxxml8zngyW1E2oxeSrrVxyWrB0bR8J6a+mRWgbAbQWOPnaplOJevLIjkq5 FdPKq36Gbup4ECaT8+kyAuG0lDtF5RQELGGtWaSYC4cDY+8NWdSCwR3ii0eRnaTKDxyf mkW56zv/lKx96qwMJoq8uHuoL5gEyyz82iiWEXCj2DGAL0votcD4uvN4fHH8cMrLyHYM HbqrXLIozqKTI4k8aKgaDUNFcJYEGciGtKgVck3ZkAoWjGKX5CiVScsP8Al6M445slF/ 3Xh1m9svAtp+DV31G16VgLraZOeyFdWtXG6hjSr11/0va2AH07YMW+J7zujwwlLroV0j Y0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719610617; x=1720215417; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zdLWS2vCtwF4XqHOD2o3vypJvE6S4oRWVuw0s9SQRcQ=; b=LRrJuPTbmu2e12nHkU89x5Zo4LJV2a9MyKdrjJXc2KGRUe1H5BTT4tAGedAOlBBZ/f ut9lqiOKgGV7FRW4EPiPCOxJXsxDGpWIXEf/cP4NjTZH2pRBWx16ChxH0XTcWWYYgmfy kwyKokvJxPLmHRUL9Iwa0YZi4nyhjjyCFFfrdFOqZ68DWMK9Ri7o7Zj8+C32t2q/Ak67 gS0F39gw8Qk8aDwhx/1IPT/kGFsdOcoeALyxh6Cvxm7uAWuPIHHhB8SsgXqQtr8EbSS4 Vmcjd13RuxwtrpcSVPOF3b9PDUxBs1t7qjdKesbUTadUjoZq7TyZmE2i5bOiZLZuMJf3 uzpQ== X-Gm-Message-State: AOJu0Yznc1FvgxGmFqEcs4wukUmnmEIuIxoUuYyrhUnEoJfZZEQiO4k9 yaV5Qq2+mNNGXlg2PFBihJR6qy3deHPxGewKj1y7Ml7vru9+U7fs9ANlLA== X-Google-Smtp-Source: AGHT+IHJFfjkdCGf9514O7AfUW9jr10UY/E6FaHKYuksC97wIithY5ZxQDMuuIr/rbOXb+J9A501Gw== X-Received: by 2002:a05:600c:3ba9:b0:425:6911:eb00 with SMTP id 5b1f17b1804b1-4256911ec79mr29376935e9.5.1719610616733; Fri, 28 Jun 2024 14:36:56 -0700 (PDT) Received: from [192.168.0.104] (178-117-134-240.access.telenet.be. [178.117.134.240]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b099c7dsm52156305e9.38.2024.06.28.14.36.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 14:36:56 -0700 (PDT) Message-ID: <71a73b87-cc2f-4ee5-a961-7bf2b191fbb6@gmail.com> Date: Fri, 28 Jun 2024 23:35:36 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API To: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: dossche.niels@gmail.com (Niels Dossche) On 28/06/2024 22:06, Máté Kocsis wrote: > Hi Everyone, > > I've been working on a new RFC for a while now, and time has come to present it to a wider audience. > > Last year, I learnt that PHP doesn't have built-in support for parsing URLs according to any well established standards (RFC 1738 or the WHATWG URL living standard), since the parse_url() function is optimized for performance instead of correctness. > > In order to improve compatibility with external tools consuming URLs (like browsers), my new RFC would add a WHATWG compliant URL parser functionality to the standard library. The API itself is not final by any means, the RFC only represents how I imagined it first. > > You can find the RFC at the following link: https://wiki.php.net/rfc/url_parsing_api > > Regards, > Máté > Hi Máté +1 from me, I'm all for modern web-related APIs as you know. Some questions/remarks: - Why did you choose UrlParser to be a "static" class? Right now it's just a fancy namespace. I can see the point of having a UrlParser class where you can e.g. configure it with which URL standard you want, but as it is now there is no such capability. - It's a bit of a shame that the PSR interface treats queries as strings. In Javascript we have the URLSearchParams class that we can use as a key-value storage for query parameters. This Javascript class also handles escaping them nicely. - Why is UrlComponent a backed enum? - A nit: We didn't bundle the entire Lexbor engine, only select parts of it. Just thought I'd make it clear. - About edge cases: e.g. what happens if I call the Url constructor and leave every string field empty? Overall seems good. Kind regards Niels