Skip to content

Commit

Permalink
Merge pull request #14836 from ruudboon/fixes/char-issue-request-2058
Browse files Browse the repository at this point in the history
Fixed MacOS char issue
  • Loading branch information
ruudboon authored Feb 11, 2020
2 parents e7f3305 + 56357d2 commit 14448fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixed `Phalcon\Cli\Console` to pass current container to the `Phalcon\Mvc\ModuleDefinitionInterface::registerAutoloaders()` [#14787](https://github.com/phalcon/cphalcon/issues/14787) [@TimurFlush](https://github.com/TimurFlush)
- Fixed `Phalcon\Db\Dialect\Mysql::createTable()` to create default value with CURRENT_TIMESTAMP ON UPDATE/DELETE [#14797]
- Fixed `Phalcon\Storage\Adapter\*` to no longer accept the `serializer` option as it was clashing with the factory [#14828](https://github.com/phalcon/cphalcon/pull/14828)
- Fixed `Phalcon\Http\Request` to return the correct host on an `UnexpectedValueException` [#14763](https://github.com/phalcon/cphalcon/issues/14763)

# [4.0.3](https://github.com/phalcon/cphalcon/releases/tag/v4.0.3) (2020-01-25)
## Added
Expand Down
14 changes: 8 additions & 6 deletions phalcon/Http/Request.zep
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class Request extends AbstractInjectionAware implements RequestInterface
*/
public function getHttpHost() -> string
{
var host, strict;
var host, strict, cleanHost;

let strict = this->strictHostCheck;

Expand All @@ -459,25 +459,27 @@ class Request extends AbstractInjectionAware implements RequestInterface
/**
* Cleanup. Force lowercase as per RFC 952/2181
*/
let host = strtolower(
let cleanHost = strtolower(
trim(host)
);

if memstr(host, ":") {
let host = preg_replace("/:[[:digit:]]+$/", "", host);
if memstr(cleanHost, ":") {
let cleanHost = preg_replace("/:[[:digit:]]+$/", "", cleanHost);
}

/**
* Host may contain only the ASCII letters 'a' through 'z'
* (in a case-insensitive manner), the digits '0' through '9', and
* the hyphen ('-') as per RFC 952/2181
*/
if unlikely ("" !== preg_replace("/[a-z0-9-]+\.?/", "", host)) {
if unlikely ("" !== preg_replace("/[a-z0-9-]+\.?/", "", cleanHost)) {
throw new UnexpectedValueException("Invalid host " . host);
}
} else {
let cleanHost = host;
}

return (string) host;
return (string) cleanHost;
}

/**
Expand Down

0 comments on commit 14448fb

Please sign in to comment.