Skip to content

Commit

Permalink
Merge branch 'master' into improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
l0gicgate authored Feb 12, 2023
2 parents c8b9c6a + a5327c8 commit f690015
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2]
php: [8.0, 8.1, 8.2]
experimental: [false]
include:
- php: 8.1
- php: 8.2
analysis: true
- php: nightly
experimental: true

steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP ${{ matrix.php }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ composer require slim/psr7

This will install the `slim/psr7` component and all required dependencies.

PHP 7.4 or newer is required.
PHP 8.0 or newer is required.

## Tests

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"fig/http-message-util": "^1.1.5",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
Expand Down
12 changes: 8 additions & 4 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use function preg_replace_callback;
use function rawurlencode;
use function str_replace;
use function str_starts_with;
use function strtolower;

use const FILTER_FLAG_IPV6;
Expand Down Expand Up @@ -311,6 +312,11 @@ protected function filterPort($port): ?int
*/
public function getPath(): string
{
if (str_starts_with($this->path, '/')) {
// Use only one leading slash to prevent XSS attempts.
return '/' . ltrim($this->path, '/');
}

return $this->path;
}

Expand Down Expand Up @@ -346,9 +352,7 @@ protected function filterPath($path): string
{
$match = preg_replace_callback(
'/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
function ($match) {
return rawurlencode($match[0]);
},
fn (array $match) => rawurlencode($match[0]),
$path
);

Expand Down Expand Up @@ -466,7 +470,7 @@ public function __toString(): string
{
$scheme = $this->getScheme();
$authority = $this->getAuthority();
$path = $this->getPath();
$path = $this->path;
$query = $this->getQuery();
$fragment = $this->getFragment();

Expand Down

0 comments on commit f690015

Please sign in to comment.