Skip to content

Commit

Permalink
Fix already encoded userinfo to Uri (#22)
Browse files Browse the repository at this point in the history
* Allow latest version of php-http/psr7-integration-tests

* Fix already encoded userinfo to Uri
  • Loading branch information
devanych committed May 6, 2023
1 parent d60d87a commit 2b2b114
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"php-http/psr7-integration-tests": "1.2",
"php-http/psr7-integration-tests": "^1.3",
"squizlabs/php_codesniffer": "^3.7",
"vimeo/psalm": "^4.9|^5.2"
},
Expand Down
8 changes: 4 additions & 4 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private function normalizeUserInfo(string $user, ?string $pass = null): string
return '';
}

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

if ($pass !== null) {
Expand Down Expand Up @@ -454,7 +454,7 @@ private function normalizePath(string $path): string
return $path;
}

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

/**
Expand All @@ -474,7 +474,7 @@ private function normalizeQuery(string $query): string
$query = ltrim($query, '?');
}

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

/**
Expand All @@ -493,7 +493,7 @@ private function normalizeFragment(string $fragment): string
$fragment = ltrim($fragment, '#');
}

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

/**
Expand Down

0 comments on commit 2b2b114

Please sign in to comment.