Skip to content

Commit

Permalink
Merge branch 'Sam-Burns-php71' into 4.x
Browse files Browse the repository at this point in the history
Forward port #2117
  • Loading branch information
akrabat committed Jan 7, 2017
2 parents 1ee23ae + 795e036 commit 4fe9cea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ php:
- 7.1
- hhvm

matrix:
allow_failures:
- php: 7.1

before_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then composer require satooshi/php-coveralls:1.* squizlabs/php_codesniffer:2.* -n ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then composer install -n ; fi
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static function parseHeader($header)
}

$header = rtrim($header, "\r\n");
$pieces = preg_split('@\s*[;,]\s*@', $header);
$pieces = preg_split('@[;]\s*@', $header);
$cookies = [];

foreach ($pieces as $cookie) {
Expand Down
21 changes: 17 additions & 4 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,22 @@ public function testRespondNoContent()
public function testRespondWithPaddedStreamFilterOutput()
{
$availableFilter = stream_get_filters();
if (in_array('mcrypt.*', $availableFilter) && in_array('mdecrypt.*', $availableFilter)) {

if (version_compare(phpversion(), '7.0.0', '>=')) {
$filterName = 'string.rot13';
$unfilterName = 'string.rot13';
$specificFilterName = 'string.rot13';
$specificUnfilterName = 'string.rot13';
} else {
$filterName = 'mcrypt.*';
$unfilterName = 'mdecrypt.*';
$specificFilterName = 'mcrypt.rijndael-128';
$specificUnfilterName = 'mdecrypt.rijndael-128';
}

if (in_array($filterName, $availableFilter) && in_array($unfilterName, $availableFilter)) {
$app = new App();
$app->get('/foo', function ($req, $res) {
$app->get('/foo', function ($req, $res) use ($specificFilterName, $specificUnfilterName) {
$key = base64_decode('xxxxxxxxxxxxxxxx');
$iv = base64_decode('Z6wNDk9LogWI4HYlRu0mng==');

Expand All @@ -1553,7 +1566,7 @@ public function testRespondWithPaddedStreamFilterOutput()

$stream = fopen('php://temp', 'r+');

$filter = stream_filter_append($stream, 'mcrypt.rijndael-128', STREAM_FILTER_WRITE, [
$filter = stream_filter_append($stream, $specificFilterName, STREAM_FILTER_WRITE, [
'key' => $key,
'iv' => $iv
]);
Expand All @@ -1562,7 +1575,7 @@ public function testRespondWithPaddedStreamFilterOutput()
rewind($stream);
stream_filter_remove($filter);

stream_filter_append($stream, 'mdecrypt.rijndael-128', STREAM_FILTER_READ, [
stream_filter_append($stream, $specificUnfilterName, STREAM_FILTER_READ, [
'key' => $key,
'iv' => $iv
]);
Expand Down
7 changes: 7 additions & 0 deletions tests/Http/CookiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ public function testParseHeader()
$this->assertEquals('Josh', $cookies['name']);
}

public function testParseHeaderWithJsonArray()
{
$cookies = Cookies::parseHeader('foo=bar; testarray=["someVar1","someVar2","someVar3"]');
$this->assertEquals('bar', $cookies['foo']);
$this->assertContains('someVar3', json_decode($cookies['testarray']));
}

public function testToHeaders()
{
$cookies = new Cookies;
Expand Down

0 comments on commit 4fe9cea

Please sign in to comment.