Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13777 invoked from network); 12 May 2017 00:39:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2017 00:39:24 -0000 Authentication-Results: pb1.pair.com header.from=zardozrocks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zardozrocks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.169 as permitted sender) X-PHP-List-Original-Sender: zardozrocks@gmail.com X-Host-Fingerprint: 209.85.216.169 mail-qt0-f169.google.com Received: from [209.85.216.169] ([209.85.216.169:35537] helo=mail-qt0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 77/A3-11470-A3405195 for ; Thu, 11 May 2017 20:39:22 -0400 Received: by mail-qt0-f169.google.com with SMTP id v27so18321270qtg.2 for ; Thu, 11 May 2017 17:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=YFtaHbnbRsnzQw5KojZqlaLKcGu0QaFUeE6s1RSMb7g=; b=eua87Y3Nh3yPhLfjZScgcs7t0GYr0KGYVlkDTlaaKbsYFDboi4rSUDNBdh129mdseK Nll0w4UP1U9nqHmjshbqHjqxnW9ddRLkm4ucOpW8DAz5TgGY1hvCgpDQOzrnWSx575J4 AFqNdSL68s7r3kFKjVo8TDJCB9+TLektZvTkMtNXkx/xFq9DzffHjPAWUqRFVh7M2nQx GFsFRfEwZnjV0B9E7fFguvL8uKZ54PyIxWKfbNxWTEWgHpgHISzubHuQIoGIMYqOrXHW MDk8jkjDjve54nfdOGxAvkVz0M5nMFZbPSFVk7LfFyCTK3NtgLgOS5VzBAQfZEovEXo3 yA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YFtaHbnbRsnzQw5KojZqlaLKcGu0QaFUeE6s1RSMb7g=; b=cBAtZA1Hm4hgArlz/imtPmLvrCEsrnR0XZ+5V5erJcDUbChwZrUSR3sClrkUvMSyVd Q+JxsYBdcbdSsbsXhnsNxsT4eVXLEh0L8k/Gh1ktUY4BOt8regAaP63GJcpiXi5tF9Qv ZI+TcpMO53sDqjTePtNDWXP9tLnN8pTUfe3O5WBr5WrVHqevtJT+omW9YUEZLZn3iOdg VvBbth1C9Ponbt72Xoac5EqbkpISMCkSssFZtf4zeH9WUAb04mNFApiez2UklSU4cPQh trylTXUk41krZf+M3aM0OChpP3Mwz86b63Dy5hsaKgu41+y4uEPS1fH8hc7FqsJBD1LZ MkMg== X-Gm-Message-State: AODbwcDxI5RNwu+cBzYifb+k74KAuTrIsDVdjoncLZCkBE6nuO9yqsdT xB3piWP2KEMcGF7ZpFT6MaxsOcs17rm3 X-Received: by 10.237.37.228 with SMTP id y33mr1284048qtc.280.1494549559543; Thu, 11 May 2017 17:39:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.184.174 with HTTP; Thu, 11 May 2017 17:39:19 -0700 (PDT) Date: Thu, 11 May 2017 17:39:19 -0700 Message-ID: To: internals Content-Type: multipart/alternative; boundary="001a1140d9f4988d13054f48ef8c" Subject: filter_var url validation needs help From: zardozrocks@gmail.com (j adams) --001a1140d9f4988d13054f48ef8c Content-Type: text/plain; charset="UTF-8" Forgive me if I'm contacting the wrong list. If I am, someone please tell me who I should contact about this. I have been telling noob programmers for years to use filter_var with FILTER_VALIDATE_URL to validate urls but recently ran into some pretty disappointing behavior with it. It would appear from this 10-year-old bug report and the source code that iliaa@php.net made some pretty drastic changes to "fix" a problem: https://bugs.php.net/bug.php?id=39898 A friend helping me look into it says there was apparently a change between 5.2.0 and 5.2.1 that removed some important-looking flag handling: > diff museum.php.net/php5/php-5.2.0/ext/filter/logical_filters.c museum.php.net/php5/php-5.2.1/ext/filter/logical_filters.c > diff.txt ... 488,491c457,460 < if ( < ((flags & FILTER_FLAG_SCHEME_REQUIRED) && url->scheme == NULL) || < ((flags & FILTER_FLAG_HOST_REQUIRED) && url->host == NULL) || < ((flags & FILTER_FLAG_PATH_REQUIRED) && url->path == NULL) || < ((flags & FILTER_FLAG_QUERY_REQUIRED) && url->query == NULL) < ) { if ( > url->scheme == NULL || > /* some schemas allow the host to be empty */ > (url->host == NULL && (strcmp(url->scheme, "mailto") && strcmp(url->scheme, "news") && strcmp(url->scheme, "file"))) || > ((flags & FILTER_FLAG_PATH_REQUIRED) && url->path == NULL) || ((flags & FILTER_FLAG_QUERY_REQUIRED) && url->query == NULL) > ) { >bad_url: > php_url_free(url); > RETURN_VALIDATION_FAILED The docs here also say that this function supports the nearly-20-year-old RFC 2396, which has been obsoleted by RFC 3986 (which, in turn, is updated by 6874 and 7320) http://php.net/manual/en/filter.filters.validate.php Contrary to what the docs say, FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED don't do anything. This is very disappointing and should probably be remedied -- at the very least the documentation should be updated to remove the ignored flags. There appear to be quite a few problems with the function: https://bugs.php.net/search.php?cmd=display&search_for=FILTER_VALIDATE_URL --001a1140d9f4988d13054f48ef8c--