Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106240 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22044 invoked from network); 18 Jul 2019 23:14:28 -0000 Received: from unknown (HELO mail-qt1-f179.google.com) (209.85.160.179) by pb1.pair.com with SMTP; 18 Jul 2019 23:14:28 -0000 Received: by mail-qt1-f179.google.com with SMTP id k10so28727255qtq.1 for ; Thu, 18 Jul 2019 13:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YIIXLCZyNwer5HULh/z4kIz1o2bTxnawAbyD1cciJYo=; b=RE/vVDmDS75EylIImMH8PPrAHkF6Ti5On9+DFWuFMqsAaQKdqXJ2qLl22Tg7mKcLiV MNvx1kD2ecHC/qG1m+MDEbFHL2h8xyFL22Pec68oyq3Modd7f4xXu9GL8uUnadxg7MtG CmADGtXANS6TIMBX8k+tRA6nQSef5retDlBBuH7jnRc8NkFmiPlWQR4ozAtJu4LwWZee GJ0Kg2JeOYux1Uj2WJcxTy2P+eNQht9bTzCokojBzwaBAgxQkdK9djSgr4GNVRe+VYPj EqyO1faQO9+Yj63SnuVDHVC6q301gIrib0+yI+0Ky5GPXaFh6SHrtLmaNLZ0yWvsA3ZY PWEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YIIXLCZyNwer5HULh/z4kIz1o2bTxnawAbyD1cciJYo=; b=j3sKn1YZ4eRr4Zr7uB+b1OLwjIHOBx5+mVUZT+1mz+t2r1MmzU+IQoN6qZhd2Nn/dW q2FXS2UUs3H8HgoKH1kDar3oqZ+X3jNV5qVWhJJ4nyWwx8kEoqQJkxXoz+oevE/U5OAD 16uE0L9iEp8/HrP9OIsuaqWyhm+Q9WywzcDyzTdYGnwA4L6FQL3sBBY2RpCEUWwTiYGj wYXtxt5fsokBrbVjgBuxvKAQ3HuEiKK+3sI1gMCOFBXaoFR0czObGGyNYRK3q8kXakYD JuniL6ZP7fK0VMw0AcYvhswUBbmSW8D7qeLzIkikzZ0m9ncBUeuvFus9k97YYw+4zdeV gW1A== X-Gm-Message-State: APjAAAUSk6DNVu8LY9aC/ZDe55zICRegyOxacs/OlTB7G+YUuu4TQMIe Pi03s99Ayv9mhRndbgthMYBMBYxPgpq1sBnSj7o= X-Google-Smtp-Source: APXvYqwRxTqDsZ542eeo2yamwaZwS+vD7ELvP2BEYFAfPPYA+EOXkV1F50oZ5JKiOvI/1/sE22aOkI715lgyhgUF8wg= X-Received: by 2002:aed:23ef:: with SMTP id k44mr32898037qtc.202.1563482186349; Thu, 18 Jul 2019 13:36:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 18 Jul 2019 22:36:16 +0200 Message-ID: To: Dan Ackroyd Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000548ed1058dfa9016" Subject: Re: [PHP-DEV] Stop replacing dots with underscores in query, post and cookie parameters for PHP 8? From: rasmus@mindplay.dk (Rasmus Schultz) --000000000000548ed1058dfa9016 Content-Type: text/plain; charset="UTF-8" On Thu, Jul 18, 2019 at 4:28 PM Dan Ackroyd wrote: > On Thu, 18 Jul 2019 at 11:08, Rasmus Schultz wrote: > > > > What about ... > > Although there might be real problems for this, please can you > describe a concrete problem that will occur, in a library people use, > rather than a vague possible problem? > Well, both underscores and hyphens are permitted in header names - so a library that replaces underscores with hyphens potentially mangles real header names. (Mangling and unmangling are both lossy operations.) > For most framework users, all of the request variables are only > accessed through either a PSR7 request object or their framework > specific equivalent, and the problem of mangling/demangling can be > solved there. > Yes, that's my concern - if they don't know whether the names are already mangled or not, they might apply the unmangling, unintentionally mangling actual valid header names. Besides also wasting some CPU time - no point in processing header-names if they're already properly formatted. Mainly, all I'm suggesting is that there be some way to tell if the names were either never mangled, or have already been unmangled, so we can avoid single or multiple (redundant and/or lossy) mangling/unmangling operations in the polyfill and PSR-7 libraries. Since this has to do with $_SERVER, it seems natural to keep it in $_SERVER["REAL_HEADER_NAMES"], which would be set to true on PHP 8. So in the polyfill: if (isset($_SERVER["REAL_HEADER_NAMES"])) { // mangle names... unset($_SERVER["REAL_HEADER_NAMES"]); } And in the PSR-7 libraries: if (isset($_SERVER["REAL_HEADER_NAMES"])) { // use names as is } else { // unmangle names } This is just an example - I'm indifferent as to the name and location of this value. Someone suggested using a constant, but you can't unset a constant - for the polyfill and PHP 8 both to be seen by a PSR-7 library as having real header names, the polyfill needs to be able to clear that flag. (With a constant, you'd need an additional check against php_version() - just trying to keep this as simple as possible.) --000000000000548ed1058dfa9016--