Skip to content

Commit

Permalink
Merge pull request #55 from thephpleague/2.4.x-fix-query-encoding
Browse files Browse the repository at this point in the history
#109 Fix query encoding
  • Loading branch information
nyamsprod authored Aug 13, 2023
2 parents 06f49e7 + 417fe03 commit c938372
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
8 changes: 3 additions & 5 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'no_empty_comment' => true,
'no_leading_import_slash' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'ordered_imports' => [
'imports_order' => [
Expand All @@ -58,9 +58,7 @@
],
'sort_algorithm' => 'alpha',
],
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => false,
],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
Expand All @@ -71,7 +69,7 @@
'return_type_declaration' => [
'space_before' => 'none',
],
'single_blank_line_before_namespace' => true,
'blank_lines_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'ternary_operator_spaces' => true,
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

All Notable changes to `League\Uri\Components` will be documented in this file

## [2.4.2](https://github.com/thephpleague/uri-components/compare/2.4.1...2.4.2) - 2023-08-12

### Added

- None

### Fixed

- conversion query component for non ASCII characters see [#109](https://github.com/thephpleague/uri-src/issues/109)

### Deprecated

- None

### Remove

- None

## 2.4.0 - 2021-08-02

## [2.4.1](https://github.com/thephpleague/uri-components/compare/2.4.0...2.4.1) - 2022-05-26

### Added
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"psr/http-message": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.8.0",
"friendsofphp/php-cs-fixer": "^v3.22.0",
"guzzlehttp/psr7": "^2.2",
"league/uri": "^6.0",
"phpstan/phpstan": "^1.7",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpunit/phpunit": "^9.5.20",
"laminas/laminas-diactoros": "^2.11.0"
"phpstan/phpstan": "^1.10.28",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpstan/phpstan-deprecation-rules": "^1.1.4",
"phpunit/phpunit": "^9.6.10",
"laminas/laminas-diactoros": "^2.11"
},
"suggest": {
"ext-intl": "to handle IDN host",
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HierarchicalPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function getBasename(): string
*/
public function getExtension(): string
{
[$basename, ] = explode(';', $this->getBasename(), 2);
[$basename] = explode(';', $this->getBasename(), 2);

return pathinfo($basename, PATHINFO_EXTENSION);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public function withoutZoneIdentifier(): IpHostInterface
return $this;
}

[$ipv6, ] = explode('%', substr((string) $this->host, 1, -1));
[$ipv6] = explode('%', substr((string) $this->host, 1, -1));

return static::createFromIp($ipv6);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function testStringRepresentationComponent($input, $expected): void

public function queryProvider(): array
{
$unreserved = 'a-zA-Z0-9.-_~!$&\'()*+,;=:@';
$unreserved = 'a-zA-Z0-9.-_~!$&\'()*,;=:@';

return [
'bug fix issue 84' => ['fào=?%25bar&q=v%61lue', 'f%C3%A0o=?%25bar&q=value'],
Expand Down
6 changes: 3 additions & 3 deletions src/QueryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ final class QueryString
'suffixValue' => '*&',
],
PHP_QUERY_RFC3986 => [
'suffixKey' => "!$'()*+,;:@?/%",
'suffixValue' => "!$'()*+,;=:@?/&%",
'suffixKey' => "!$'()*,;:@?/%",
'suffixValue' => "!$'()*,;=:@?/&%",
],
];

Expand Down Expand Up @@ -293,7 +293,7 @@ public static function build(iterable $pairs, string $separator = '&', int $enc_

$query = implode($separator, $res);
if (PHP_QUERY_RFC1738 === $enc_type) {
return str_replace(['+', '%20'], ['%2B', '+'], $query);
return str_replace('%20', '+', $query);
}

return $query;
Expand Down
6 changes: 3 additions & 3 deletions src/QueryStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ public function buildProvider(): array
'expected_rfc3986' => '0=0',
],
'rcf1738' => [
'pairs' => [['toto', 'foo+bar']],
'expected_rfc1738' => 'toto=foo%2Bbar',
'expected_rfc3986' => 'toto=foo+bar',
'pairs' => [['toto', 'foo+bar toto']],
'expected_rfc1738' => 'toto=foo%2Bbar+toto',
'expected_rfc3986' => 'toto=foo%2Bbar%20toto',
],
'utf-8 characters' => [
'pairs' => [["\v\xED", "\v\xED"]],
Expand Down

0 comments on commit c938372

Please sign in to comment.