Update guzzlehttp/psr7 to a custom fork
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 20 Mar 2022 14:22:29 +0000 (15:22 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 21 Mar 2022 10:00:36 +0000 (11:00 +0100)
see WoltLab/guzzle-psr7@ff7be9fcf7da87f971990b1a61d8a7f2b5aeac9b
see WoltLab/guzzle-psr7@986596de01529f6e837a5cadfef9ec714ace7914

wcfsetup/install/files/lib/system/api/bin/pscss [changed from symlink to file mode: 0644]
wcfsetup/install/files/lib/system/api/composer.json
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/ClassLoader.php
wcfsetup/install/files/lib/system/api/composer/InstalledVersions.php
wcfsetup/install/files/lib/system/api/composer/autoload_real.php
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/guzzlehttp/psr7/src/MessageTrait.php

deleted file mode 120000 (symlink)
index d08fca2ff6d8193e66fe6d02d1b688708f589341..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../scssphp/scssphp/bin/pscss
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..f563d0caeba63b90ddc02a7edfa7624c887e5e80
--- /dev/null
@@ -0,0 +1,117 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Proxy PHP file generated by Composer
+ *
+ * This file includes the referenced bin path (../scssphp/scssphp/bin/pscss)
+ * using a stream wrapper to prevent the shebang from being output on PHP<8
+ *
+ * @generated
+ */
+
+namespace Composer;
+
+$GLOBALS['_composer_bin_dir'] = __DIR__;
+$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
+
+if (PHP_VERSION_ID < 80000) {
+    if (!class_exists('Composer\BinProxyWrapper')) {
+        /**
+         * @internal
+         */
+        final class BinProxyWrapper
+        {
+            private $handle;
+            private $position;
+            private $realpath;
+
+            public function stream_open($path, $mode, $options, &$opened_path)
+            {
+                // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
+                $opened_path = substr($path, 17);
+                $this->realpath = realpath($opened_path) ?: $opened_path;
+                $opened_path = $this->realpath;
+                $this->handle = fopen($this->realpath, $mode);
+                $this->position = 0;
+
+                return (bool) $this->handle;
+            }
+
+            public function stream_read($count)
+            {
+                $data = fread($this->handle, $count);
+
+                if ($this->position === 0) {
+                    $data = preg_replace('{^#!.*\r?\n}', '', $data);
+                }
+
+                $this->position += strlen($data);
+
+                return $data;
+            }
+
+            public function stream_cast($castAs)
+            {
+                return $this->handle;
+            }
+
+            public function stream_close()
+            {
+                fclose($this->handle);
+            }
+
+            public function stream_lock($operation)
+            {
+                return $operation ? flock($this->handle, $operation) : true;
+            }
+
+            public function stream_seek($offset, $whence)
+            {
+                if (0 === fseek($this->handle, $offset, $whence)) {
+                    $this->position = ftell($this->handle);
+                    return true;
+                }
+
+                return false;
+            }
+
+            public function stream_tell()
+            {
+                return $this->position;
+            }
+
+            public function stream_eof()
+            {
+                return feof($this->handle);
+            }
+
+            public function stream_stat()
+            {
+                return array();
+            }
+
+            public function stream_set_option($option, $arg1, $arg2)
+            {
+                return true;
+            }
+
+            public function url_stat($path, $flags)
+            {
+                $path = substr($path, 17);
+                if (file_exists($path)) {
+                    return stat($path);
+                }
+
+                return false;
+            }
+        }
+    }
+
+    if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
+        include("phpvfscomposer://" . __DIR__ . '/..'.'/scssphp/scssphp/bin/pscss');
+        exit(0);
+    }
+}
+
+include __DIR__ . '/..'.'/scssphp/scssphp/bin/pscss';
index da977f942c90a9e6a1ed67429eb5594513750d78..f84c253c1892350632f1f615be16579e871204fb 100644 (file)
         "true/punycode": "~2.0",
         "pear/net_idna2": "^0.2.0",
         "scssphp/scssphp": "^1.3",
-        "guzzlehttp/guzzle": "dev-6.5-woltlab"
+        "guzzlehttp/guzzle": "dev-6.5-woltlab",
+        "guzzlehttp/psr7": "dev-woltlab-1.6.1 as 1.6.1"
     },
     "repositories": [
         {
             "type": "vcs",
             "url": "https://github.com/WoltLab/guzzle",
             "no-api": true
+        },
+        {
+            "type": "vcs",
+            "url": "https://github.com/WoltLab/guzzle-psr7",
+            "no-api": true
         }
     ]
 }
index 42f21211ffe955cfb613f25a2661dcd363ca5bed..fc6e05fd96eb014da00763f80dff9fd2d55af6d4 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "e4709905ac8ea201053fb79a4a25e0da",
+    "content-hash": "1c5d2894e134ffd3d6d48cde54301194",
     "packages": [
         {
             "name": "chrisjean/php-ico",
         },
         {
             "name": "guzzlehttp/psr7",
-            "version": "1.6.1",
+            "version": "dev-woltlab-1.6.1",
             "source": {
                 "type": "git",
-                "url": "https://github.com/guzzle/psr7.git",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
+                "url": "https://github.com/WoltLab/guzzle-psr7",
+                "reference": "986596de01529f6e837a5cadfef9ec714ace7914"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
+                "url": "https://api.github.com/repos/WoltLab/guzzle-psr7/zipball/986596de01529f6e837a5cadfef9ec714ace7914",
+                "reference": "986596de01529f6e837a5cadfef9ec714ace7914",
                 "shasum": ""
             },
             "require": {
                     "src/functions_include.php"
                 ]
             },
-            "notification-url": "https://packagist.org/downloads/",
+            "autoload-dev": {
+                "psr-4": {
+                    "GuzzleHttp\\Tests\\Psr7\\": "tests/"
+                }
+            },
             "license": [
                 "MIT"
             ],
                 "uri",
                 "url"
             ],
-            "time": "2019-07-01T23:21:34+00:00"
+            "time": "2022-03-20T21:51:18+00:00"
         },
         {
             "name": "pear/net_idna2",
         }
     ],
     "packages-dev": [],
-    "aliases": [],
+    "aliases": [
+        {
+            "package": "guzzlehttp/psr7",
+            "version": "dev-woltlab-1.6.1",
+            "alias": "1.6.1",
+            "alias_normalized": "1.6.1.0"
+        }
+    ],
     "minimum-stability": "stable",
     "stability-flags": {
-        "guzzlehttp/guzzle": 20
+        "guzzlehttp/guzzle": 20,
+        "guzzlehttp/psr7": 20
     },
     "prefer-stable": false,
     "prefer-lowest": false,
index 0cd6055d1b7943ea1a8c5f45630517b4f2d56b59..afef3fa2ad83f114c8de5487e869f9c9b8a459bf 100644 (file)
@@ -149,7 +149,7 @@ class ClassLoader
 
     /**
      * @return string[] Array of classname => path
-     * @psalm-var array<string, string>
+     * @psalm-return array<string, string>
      */
     public function getClassMap()
     {
index d49798780383ace603ac075f823a2a922799765d..53f3ab79303c42eb4ef3e4b838cdbfa233b756e7 100644 (file)
@@ -1,5 +1,15 @@
 <?php
 
+
+
+
+
+
+
+
+
+
+
 namespace Composer;
 
 use Composer\Semver\VersionParser;
@@ -80,12 +90,13 @@ private static $installed = array (
     ),
     'guzzlehttp/psr7' => 
     array (
-      'pretty_version' => '1.6.1',
-      'version' => '1.6.1.0',
+      'pretty_version' => 'dev-woltlab-1.6.1',
+      'version' => 'dev-woltlab-1.6.1',
       'aliases' => 
       array (
+        0 => '1.6.1',
       ),
-      'reference' => '239400de7a173fe9901b9ac7c06497751f00727a',
+      'reference' => '986596de01529f6e837a5cadfef9ec714ace7914',
     ),
     'pear/net_idna2' => 
     array (
index 4f5bbe12a758cd74256100e484a8249ede80cc6e..98df932e4b6d9e8497eab7a1f1cd2248bbd96627 100644 (file)
@@ -69,11 +69,16 @@ class ComposerAutoloaderInitf07e6bf6487a19c1ad4a7f66aa2be118
     }
 }
 
+/**
+ * @param string $fileIdentifier
+ * @param string $file
+ * @return void
+ */
 function composerRequiref07e6bf6487a19c1ad4a7f66aa2be118($fileIdentifier, $file)
 {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
-        require $file;
-
         $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
+
+        require $file;
     }
 }
index eb791ec8488960c7a44940f39e2c0dd23176bb13..3c04e00e14b8ce81890f842c564953d518c8dee4 100644 (file)
         },
         {
             "name": "guzzlehttp/psr7",
-            "version": "1.6.1",
-            "version_normalized": "1.6.1.0",
+            "version": "dev-woltlab-1.6.1",
+            "version_normalized": "dev-woltlab-1.6.1",
             "source": {
                 "type": "git",
-                "url": "https://github.com/guzzle/psr7.git",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
+                "url": "https://github.com/WoltLab/guzzle-psr7",
+                "reference": "986596de01529f6e837a5cadfef9ec714ace7914"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
-                "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
+                "url": "https://api.github.com/repos/WoltLab/guzzle-psr7/zipball/986596de01529f6e837a5cadfef9ec714ace7914",
+                "reference": "986596de01529f6e837a5cadfef9ec714ace7914",
                 "shasum": ""
             },
             "require": {
             "suggest": {
                 "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
             },
-            "time": "2019-07-01T23:21:34+00:00",
+            "time": "2022-03-20T21:51:18+00:00",
             "type": "library",
             "extra": {
                 "branch-alias": {
                     "src/functions_include.php"
                 ]
             },
-            "notification-url": "https://packagist.org/downloads/",
+            "autoload-dev": {
+                "psr-4": {
+                    "GuzzleHttp\\Tests\\Psr7\\": "tests/"
+                }
+            },
             "license": [
                 "MIT"
             ],
index c5bcebb332b7a9dff6c53cf5ff3e67443bfbb644..ed6528b2e6b488e0a24a2840484077555eb6b78b 100644 (file)
     ),
     'guzzlehttp/psr7' => 
     array (
-      'pretty_version' => '1.6.1',
-      'version' => '1.6.1.0',
+      'pretty_version' => 'dev-woltlab-1.6.1',
+      'version' => 'dev-woltlab-1.6.1',
       'aliases' => 
       array (
+        0 => '1.6.1',
       ),
-      'reference' => '239400de7a173fe9901b9ac7c06497751f00727a',
+      'reference' => '986596de01529f6e837a5cadfef9ec714ace7914',
     ),
     'pear/net_idna2' => 
     array (
index a7966d10cfb57779358ad01604b547d3e9dfe1d1..ca7969febc98857c3fa09967010775f29b970a47 100644 (file)
@@ -156,17 +156,22 @@ trait MessageTrait
         }
     }
 
+    /**
+     * @param mixed $value
+     *
+     * @return string[]
+     */
     private function normalizeHeaderValue($value)
     {
         if (!is_array($value)) {
-            return $this->trimHeaderValues([$value]);
+            return $this->trimAndValidateHeaderValues([$value]);
         }
 
         if (count($value) === 0) {
             throw new \InvalidArgumentException('Header value can not be an empty array.');
         }
 
-        return $this->trimHeaderValues($value);
+        return $this->trimAndValidateHeaderValues($value);
     }
 
     /**
@@ -177,13 +182,13 @@ trait MessageTrait
      * header-field = field-name ":" OWS field-value OWS
      * OWS          = *( SP / HTAB )
      *
-     * @param string[] $values Header values
+     * @param mixed[] $values Header values
      *
      * @return string[] Trimmed header values
      *
      * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
      */
-    private function trimHeaderValues(array $values)
+    private function trimAndValidateHeaderValues(array $values)
     {
         return array_map(function ($value) {
             if (!is_scalar($value) && null !== $value) {
@@ -193,10 +198,20 @@ trait MessageTrait
                 ));
             }
 
-            return trim((string) $value, " \t");
+            $trimmed = trim((string) $value, " \t");
+            $this->assertValue($trimmed);
+
+            return $trimmed;
         }, $values);
     }
 
+    /**
+     * @see https://tools.ietf.org/html/rfc7230#section-3.2
+     *
+     * @param mixed $header
+     *
+     * @return void
+     */
     private function assertHeader($header)
     {
         if (!is_string($header)) {
@@ -209,5 +224,46 @@ trait MessageTrait
         if ($header === '') {
             throw new \InvalidArgumentException('Header name can not be empty.');
         }
+
+        if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    '"%s" is not valid header name',
+                    $header
+                )
+            );
+        }
+    }
+
+    /**
+     * @param string $value
+     *
+     * @return void
+     *
+     * @see https://tools.ietf.org/html/rfc7230#section-3.2
+     *
+     * field-value    = *( field-content / obs-fold )
+     * field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
+     * field-vchar    = VCHAR / obs-text
+     * VCHAR          = %x21-7E
+     * obs-text       = %x80-FF
+     * obs-fold       = CRLF 1*( SP / HTAB )
+     */
+    private function assertValue($value)
+    {
+        // The regular expression intentionally does not support the obs-fold production, because as
+        // per RFC 7230#3.2.4:
+        //
+        // A sender MUST NOT generate a message that includes
+        // line folding (i.e., that has any field-value that contains a match to
+        // the obs-fold rule) unless the message is intended for packaging
+        // within the message/http media type.
+        //
+        // Clients must not send a request with line folding and a server sending folded headers is
+        // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
+        // folding is not likely to break any legitimate use case.
+        if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) {
+            throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value));
+        }
     }
 }