Fixed legacy query string encoding.
This commit is contained in:
parent
71435ba877
commit
201c6e0ab3
5 changed files with 34 additions and 28 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.2503.200311
|
0.2503.200328
|
||||||
|
|
|
@ -55,18 +55,6 @@ class UrlEncodedFormContent implements FormContent {
|
||||||
++$this->position;
|
++$this->position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all post fields as a query string.
|
|
||||||
*
|
|
||||||
* @param ?bool $spacesAsPlus null to use the Index url encoder, other wise whether to represent spaces as a + instead of %20 with the legacy encoder.
|
|
||||||
* @return string Query string representation of post fields.
|
|
||||||
*/
|
|
||||||
public function getParamString(?bool $spacesAsPlus = null): string {
|
|
||||||
return $spacesAsPlus === null
|
|
||||||
? HttpUri::buildQueryString($this->params)
|
|
||||||
: http_build_query($this->params, '', '&', $spacesAsPlus ? PHP_QUERY_RFC1738 : PHP_QUERY_RFC3986);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses URL encoded form params in a stream.
|
* Parses URL encoded form params in a stream.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
// HttpParameters.php
|
// HttpParameters.php
|
||||||
// Created: 2025-03-15
|
// Created: 2025-03-15
|
||||||
// Updated: 2025-03-15
|
// Updated: 2025-03-20
|
||||||
|
|
||||||
namespace Index\Http;
|
namespace Index\Http;
|
||||||
|
|
||||||
|
@ -84,4 +84,12 @@ interface HttpParameters {
|
||||||
array|int $options = 0,
|
array|int $options = 0,
|
||||||
mixed $default = null,
|
mixed $default = null,
|
||||||
): mixed;
|
): mixed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves parameters as a query string.
|
||||||
|
*
|
||||||
|
* @param ?bool $spacesAsPlus null to use the Index url encoder, other wise whether to represent spaces as a + instead of %20 with the legacy encoder.
|
||||||
|
* @return string Query string representation of all parameters.
|
||||||
|
*/
|
||||||
|
public function getParamString(?bool $spacesAsPlus = null): string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
// HttpParametersCommon.php
|
// HttpParametersCommon.php
|
||||||
// Created: 2025-03-15
|
// Created: 2025-03-15
|
||||||
// Updated: 2025-03-15
|
// Updated: 2025-03-20
|
||||||
|
|
||||||
namespace Index\Http;
|
namespace Index\Http;
|
||||||
|
|
||||||
|
@ -99,4 +99,26 @@ trait HttpParametersCommon {
|
||||||
? filter_var($this->params[$name][$index], $filter, $options)
|
? filter_var($this->params[$name][$index], $filter, $options)
|
||||||
: $default;
|
: $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves parameters as a query string.
|
||||||
|
*
|
||||||
|
* @param ?bool $spacesAsPlus null to use the Index url encoder, other wise whether to represent spaces as a + instead of %20 with the legacy encoder.
|
||||||
|
* @return string Query string representation of all parameters.
|
||||||
|
*/
|
||||||
|
public function getParamString(?bool $spacesAsPlus = null): string {
|
||||||
|
if($spacesAsPlus !== null) {
|
||||||
|
$params = [];
|
||||||
|
foreach($this->params as $name => $values)
|
||||||
|
$params[$name] = match(count($values)) {
|
||||||
|
0 => '',
|
||||||
|
1 => $values[0],
|
||||||
|
default => $values,
|
||||||
|
};
|
||||||
|
|
||||||
|
return http_build_query($params, '', '&', $spacesAsPlus ? PHP_QUERY_RFC1738 : PHP_QUERY_RFC3986);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpUri::buildQueryString($this->params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
// HttpRequest.php
|
// HttpRequest.php
|
||||||
// Created: 2022-02-08
|
// Created: 2022-02-08
|
||||||
// Updated: 2025-03-15
|
// Updated: 2025-03-20
|
||||||
|
|
||||||
namespace Index\Http;
|
namespace Index\Http;
|
||||||
|
|
||||||
|
@ -267,18 +267,6 @@ class HttpRequest extends HttpMessage implements ServerRequestInterface, HttpPar
|
||||||
return $this->with(params: $query);
|
return $this->with(params: $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all HTTP request query fields as a query string.
|
|
||||||
*
|
|
||||||
* @param ?bool $spacesAsPlus null to use the Index url encoder, other wise whether to represent spaces as a + instead of %20 with the legacy encoder.
|
|
||||||
* @return string Query string representation of query fields.
|
|
||||||
*/
|
|
||||||
public function getParamString(?bool $spacesAsPlus = null): string {
|
|
||||||
return $spacesAsPlus === null
|
|
||||||
? HttpUri::buildQueryString($this->params)
|
|
||||||
: http_build_query($this->params, '', '&', $spacesAsPlus ? PHP_QUERY_RFC1738 : PHP_QUERY_RFC3986);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, UploadedFileInterface[]> An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.
|
* @return array<string, UploadedFileInterface[]> An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue