Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
ParsedUri should catch IllegalArgumentException from QueryString, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey179 committed Sep 1, 2014
1 parent e2d8274 commit 8db30f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
7 changes: 6 additions & 1 deletion src/main/php/peer/ParsedUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/test/php/peer/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit 8db30f9

Please sign in to comment.