diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cbb58c..8f5fec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +5.0.1 (2014-09-01) +------------------ + + * fixed issue #119: stubbles\peer\ParsedUri should catch IllegalArgumentException from stubbles\peer\QueryString + + 5.0.0 (2014-08-17) ------------------ diff --git a/src/main/php/peer/ParsedUri.php b/src/main/php/peer/ParsedUri.php index 3b3518d..fb2b786 100644 --- a/src/main/php/peer/ParsedUri.php +++ b/src/main/php/peer/ParsedUri.php @@ -46,7 +46,12 @@ public function __construct($uri) $this->uri['host'] = strtolower($this->uri['host']); } - $this->queryString = new QueryString((isset($this->uri['query'])) ? ($this->uri['query']) : (null)); + try { + $this->queryString = new QueryString((isset($this->uri['query'])) ? ($this->uri['query']) : (null)); + } catch (\InvalidArgumentException $iae) { + throw new MalformedUriException($iae->getMessage(), $iae); + } + // bugfix for a PHP issue: ftp://user:@auxiliary.kl-s.com/ // will lead to an unset $this->uri['pass'] which is wrong // due to RFC1738 3.1, it has to be an empty string diff --git a/src/test/php/peer/UriTest.php b/src/test/php/peer/UriTest.php index 5863caf..91f8ff5 100644 --- a/src/test/php/peer/UriTest.php +++ b/src/test/php/peer/UriTest.php @@ -1032,4 +1032,15 @@ public function queryStringEqualsAddedParameters() ->queryString() ); } + + /** + * @since 5.0.1 + * @test + * @group issue_119 + * @expectedException stubbles\peer\MalformedUriException + */ + public function illegalArgumentExceptionFromUnbalancedQueryStringTurnedIntoMalformedUriException() + { + Uri::fromString('http://example.org/?foo[bar=300&baz=200'); + } }