Skip to content

Commit 2b2b114

Browse files
authored
Fix already encoded userinfo to Uri (#22)
* Allow latest version of php-http/psr7-integration-tests * Fix already encoded userinfo to Uri
1 parent d60d87a commit 2b2b114

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "^9.5",
28-
"php-http/psr7-integration-tests": "1.2",
28+
"php-http/psr7-integration-tests": "^1.3",
2929
"squizlabs/php_codesniffer": "^3.7",
3030
"vimeo/psalm": "^4.9|^5.2"
3131
},

src/Uri.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ private function normalizeUserInfo(string $user, ?string $pass = null): string
388388
return '';
389389
}
390390

391-
$pattern = '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=]+|%(?![A-Fa-f0-9]{2}))/u';
391+
$pattern = '/(?:[^%a-zA-Z0-9_\-\.~\pL!\$&\'\(\)\*\+,;=]+|%(?![A-Fa-f0-9]{2}))/u';
392392
$userInfo = $this->encode($user, $pattern);
393393

394394
if ($pass !== null) {
@@ -454,7 +454,7 @@ private function normalizePath(string $path): string
454454
return $path;
455455
}
456456

457-
return $this->encode($path, '/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/');
457+
return $this->encode($path, '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/]++|%(?![A-Fa-f0-9]{2}))/');
458458
}
459459

460460
/**
@@ -474,7 +474,7 @@ private function normalizeQuery(string $query): string
474474
$query = ltrim($query, '?');
475475
}
476476

477-
return $this->encode($query, '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/');
477+
return $this->encode($query, '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/');
478478
}
479479

480480
/**
@@ -493,7 +493,7 @@ private function normalizeFragment(string $fragment): string
493493
$fragment = ltrim($fragment, '#');
494494
}
495495

496-
return $this->encode($fragment, '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/');
496+
return $this->encode($fragment, '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/');
497497
}
498498

499499
/**

0 commit comments

Comments
 (0)