comments
authorgggeek <giunta.gaetano@gmail.com>
Sat, 25 Feb 2023 13:29:27 +0000 (13:29 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sat, 25 Feb 2023 13:29:27 +0000 (13:29 +0000)
src/Client.php
src/Helper/Charset.php
src/Helper/Http.php
src/Helper/XMLParser.php
src/Value.php

index 9ed54fc..5d97395 100644 (file)
@@ -669,7 +669,7 @@ class Client
      *
      * @todo check correctness of urlencoding cookie value (copied from php way of doing it, but php is generally sending
      *       response not requests. We do the opposite...)
-     * @todo strip invalid chars from cookie name? As per RFC6265, we should follow RFC2616, Section 2.2
+     * @todo strip invalid chars from cookie name? As per RFC 6265, we should follow RFC 2616, Section 2.2
      * @todo drop/rename $port parameter. Cookies are not isolated by port!
      * @todo feature-creep allow storing 'expires', 'secure', 'httponly' and 'samesite' cookie attributes (we could do
      *       as php, and allow $path to be an array of attributes...)
@@ -822,6 +822,7 @@ class Client
             return $this->multicall($req, $timeout, $method);
         } elseif (is_string($req)) {
             $n = new static::$requestClass('');
+            /// @todo we should somehow allow the caller to declare a custom contenttype too, esp. for the charset declaration
             $n->setPayload($req);
             $req = $n;
         }
@@ -986,7 +987,7 @@ class Client
             $uri = $path;
         }
 
-        // Cookie generation, as per RFC6265
+        // Cookie generation, as per RFC 6265
         // NB: the following code does not honour 'expires', 'path' and 'domain' cookie attributes set to client obj by the user...
         $cookieHeader = '';
         if (count($opts['cookies'])) {
index d4cadd3..9133825 100644 (file)
@@ -55,7 +55,6 @@ class Charset
     /**
      * @param string $tableName
      * @return void
-     *
      * @throws ValueErrorException for unsupported $tableName
      *
      * @todo add support for cp1252 as well as latin-2 .. latin-10
index 971ca42..1c50582 100644 (file)
@@ -11,7 +11,7 @@ class Http
     use LoggerAware;
 
     /**
-     * Decode a string that is encoded with "chunked" transfer encoding as defined in rfc2068 par. 19.4.6.
+     * Decode a string that is encoded with "chunked" transfer encoding as defined in RFC 2068 par. 19.4.6.
      * Code shamelessly stolen from nusoap library by Dietrich Ayala.
      * @internal this function will become protected in the future
      *
@@ -72,8 +72,8 @@ class Http
      * @return array with keys 'headers', 'cookies', 'raw_data' and 'status_code'
      * @throws HttpException
      *
-     * @todo if $debug is < 0, we could avoid populating 'raw_data' and 'headers' in the returned value - but that would
-     *       be a weird API...
+     * @todo if $debug is < 0, we could avoid populating 'raw_data' in the returned value - but that would
+     *       be a weird API... (note that we still need to always have headers parsed for content charset)
      */
     public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0)
     {
index c23b6fc..7676c20 100644 (file)
@@ -839,6 +839,7 @@ class XMLParser
     /**
      * xml charset encoding guessing helper function.
      * Tries to determine the charset encoding of an XML chunk received over HTTP.
+     *
      * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
      * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non-conforming (legacy?) clients/servers,
      * which will be most probably using UTF-8 anyway...
@@ -855,6 +856,8 @@ class XMLParser
      * @return string the encoding determined. Null if it can't be determined and mbstring is enabled,
      *                PhpXmlRpc::$xmlrpc_defencoding if it can't be determined and mbstring is not enabled
      *
+     * @todo as of 2023, the relevant RFC for XML Media Types is now 7303, and for HTTP it is 9110. Check if the order of
+     *       precedence implemented here is still correct
      * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!
      * @todo feature-creep make it possible to pass in options overriding usage of PhpXmlRpc static variables, to make
      *       the method independent of global state
@@ -927,10 +930,13 @@ class XMLParser
 
             return $enc;
         } else {
-            // no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
-            // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
+            // No encoding specified: assume it is iso-8859-1, as per HTTP1.1?
+            // Both RFC 2616 (HTTP 1.1) and RFC 1945 (HTTP 1.0) clearly state that for text/xxx content types
             // this should be the standard. And we should be getting text/xml as request and response.
-            // BUT we have to be backward compatible with the lib, which always used UTF-8 as default...
+            // BUT we have to be backward compatible with the lib, which always used UTF-8 as default. Moreover,
+            // RFC 7231, which obsoletes the two RFC mentioned above, has changed the rules. It says:
+            // "The default charset of ISO-8859-1 for text media types has been removed; the default is now whatever
+            // the media type definition says."
             return PhpXmlRpc::$xmlrpc_defencoding;
         }
     }
index 64a9dbe..357f206 100644 (file)
@@ -443,7 +443,6 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @param mixed $offset
      * @param mixed $value
      * @return void
-     *
      * @throws ValueErrorException|TypeErrorException
      */
     #[\ReturnTypeWillChange]
@@ -521,7 +520,6 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      *
      * @param mixed $offset
      * @return void
-     *
      * @throws ValueErrorException|StateErrorException
      */
     #[\ReturnTypeWillChange]