Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96287 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23182 invoked from network); 7 Oct 2016 13:58:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2016 13:58:11 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.179 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.213.179 mail-yb0-f179.google.com Received: from [209.85.213.179] ([209.85.213.179:34232] helo=mail-yb0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/40-20821-2F9A7F75 for ; Fri, 07 Oct 2016 09:58:10 -0400 Received: by mail-yb0-f179.google.com with SMTP id e2so16462514ybi.1 for ; Fri, 07 Oct 2016 06:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lK2JK+MwqI4Vzskv6ZislOei/nboa+TfmKy2QJ62sDQ=; b=PgDsQIt4DOCDwrZHLmHpICz5gwau2CnlxvlicBvoipOVRMZ9vLVromTVvbu0heOOfJ HaCbxtRwtyJukf+rdXKvn5AZmnlXqtYmeHFAH0PSihXZADN3lFuVzVedWmZGhnUqdG4P QhlI1DpzoCYcQHwwl2ZdC/rU6RjFjGSEBPlvalXPSmB6rXqGvqbJBs2/p8icbzncpRxT +rOTm27fbvJiqxYN/mDwWL+3DMC5K9yg98Oy5ieA181ldqjnZXi5rFPU/hB1gpNjuNqo x6JE14n2MGJooyJOLe8VTuVlh2UBEWT7sLNzCW4mTZyIqcdtBP70E0EfSuwPb8kwfvE0 bSpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lK2JK+MwqI4Vzskv6ZislOei/nboa+TfmKy2QJ62sDQ=; b=SYasL7gNC9WTGKzRujHf27gabcX0zWxC9IVj5EiHW7kLO1KxYl3Q0+X5N2N5xPOYCr PnxbHXhCyrDR/+wlCnm0GFNXBlelMytboOsslbxknXfxlFbJfXT9ayAY7QH/Cj2JG7zc j+n7zX+kh3wHhtVIPSUouDP1DRzYN/xTEkcx+rIEUDG5cnTDRTajnb6RDrm346LRdQgF uPcPVF36VBmYVQXrGQeOq946Ewe/iyYJCkHkxVhKtGAiSAIoEsq1zm7ju/0ZYcOaVkRT kXi1EfnOVCZpuouhjjT+Prb+yrRYF5qDt6XqmeJrrWRJlfvIg6Ff/FNIfUpviQ6PMZpO 9/Og== X-Gm-Message-State: AA6/9RkSu+zicbooJiwFwWcQiWOTfi27OokoQHHFWfh3fkL6YP/4VGq0oifaHsegFQseamWoKsrnXdr064o8Mg== X-Received: by 10.37.163.104 with SMTP id d95mr16161644ybi.132.1475848687121; Fri, 07 Oct 2016 06:58:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.204.129 with HTTP; Fri, 7 Oct 2016 06:58:06 -0700 (PDT) In-Reply-To: <45EED5CC-BFEE-4CB3-83A5-35D8601707DE@koalephant.com> References: <45EED5CC-BFEE-4CB3-83A5-35D8601707DE@koalephant.com> Date: Fri, 7 Oct 2016 15:58:06 +0200 Message-ID: To: Stephen Reay Cc: David Walker , PHP internals Content-Type: multipart/alternative; boundary=94eb2c19a4f0bcfb83053e46cc4f Subject: Re: [PHP-DEV] [RFC] Bug #72811 - Replacing parse_url() From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c19a4f0bcfb83053e46cc4f Content-Type: text/plain; charset=UTF-8 On Fri, Oct 7, 2016 at 2:22 PM, Stephen Reay wrote: > I think adopting the JavaScript model here is not an improvement. > > One of the strengths of parse_url is that it can parse a partial url and > give the parts that are found. How do we achieve the same using the whatwg > concept where relative URLs *require* a base url, besides using > fake://fakey.mcfakeface/fakes?faking#faker as the base url? > This strength of parse_url is also its weakness. In the FastRoute README I used to recommend that people use parse_url() to extract the path component of REQUEST_URI. It turns out that while this works for 99% of URLs it will fail in specific edge-cases, such as paths starting with more than one slash. To get correct behavior you either need to strip the query string yourself, or use parse_url() with an artificial prefix (which is the equivalent of your suggestion). > Also, the browser implementations specifically *dont* handle parsing of > the query string into a usable structure. So would we then need to create a > url object and pass it's query property to parse_str to get a useful value? > parse_url() doesn't handle this either. For the record, the URL spec does handle this in the form of URLSearchParams, but this is likely not directly transferable to PHP, because PHP interprets query strings differently. > I'm not against OO, I would just rather that if it goes that way, a solid > implementation is used, because simply copying what's used in JavaScript > sounds like a decision that will be regretted down the track. > To be clear, the URL API is not some legacy API that JS is stuck with for historic reasons. It's a relatively new addition to the point that MDN marks it as "experimental". I'm not saying that it's necessarily best to directly copy it (I'm not sufficiently familiar with the subject matter), but I do suspect that they have put significantly more thought into this than we have. Nikita --94eb2c19a4f0bcfb83053e46cc4f--