Skip to content

Commit

Permalink
Merge branch 'release/4.2.8'
Browse files Browse the repository at this point in the history
* release/4.2.8:
  updates the changelog
  validates the response data prior to saving view data
  updates the test suite
  adds support for Laravel 6
  fixes error when malicious code as referer
  • Loading branch information
austintoddj committed Sep 17, 2019
2 parents b783736 + dd1c481 commit 1b3ad47
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 135 deletions.
52 changes: 38 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,57 @@ language: php

sudo: false

php:
- 7.1
- 7.2
- 7.3
cache:
directories:
- $HOME/.composer.cache

notifications:
email: false
slack:
secure: AqHB172t10a7gJhGPSm94/eTgHmA7TcKGUBajMiIIkgp4Lmf5GP52JBp8Cip4kzkPeijawavK0pOFIs+2ps+11OAtsRNZ8TSSYIgfCD9n4GyAslFSw3QOCbVW4OcghH2GgH87dG773812DfJbUdK/HEMlu4kRVBPsoGzKK3IaTAPi9CiEq8Z8Qg9+BZkzf1a0HE/ym+ViuXKJpqQHaV5i5HFOCKV4kylEcZj4vxc9XZbx2wO/py1p9ez2YVH0cF1mxGNRqAQIjFHWtthJqldDU9Ufp9L9EKGDm7h/LK9MPGCPeFKoxvBa3wf6SDavAXgcGGZi1s24XFZklZNgSN4VaMKKa4T1PVdecQIayyoYGZX4JfXl0Bgg7I5sbVI3DeX8nSGwoGsXdli1i53aQ9feWVXGpQIJuM86NrmPFRB8qMRZcJDN8VuAyAaIKH/e5gCikG8qNgA+dphfPAY8Es3M/cJQOV29JkmFq3wddikxfQEKkJPv2Y9Q9pe8B9y5rPyFfuS7tErh/iLb68tpWSWXvgVxwqv5gx+6f0bm6J4pAvle0AuPRXBDdXwkCqdz6Ut5rI/GzzwqA3KIyDEaU1s93syfue54f29oPn27aWqoqATW41RjQCH9MkDD+4+KPFVAFYZY4oP80uFC3gBjoAvUYYTO/fypv8p/CwZ/XjNZg0=

env:
matrix:
- LARAVEL=5.8.*
- LARAVEL=dev-master

matrix:
exclude:
fast_finish: true
include:
- php: 7.1
env: LARAVEL='5.6.*' TESTBENCH='3.6.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.1
env: LARAVEL='5.6.*' TESTBENCH='3.6.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2
env: LARAVEL='5.6.*' TESTBENCH='3.6.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='5.6.*' TESTBENCH='3.6.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.1
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.1
env: LARAVEL=dev-master
allow_failures:
- env: LARAVEL=dev-master
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2
env: LARAVEL='5.8.*' TESTBENCH='3.8.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='5.8.*' TESTBENCH='3.8.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.3
env: LARAVEL='5.8.*' TESTBENCH='3.8.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.3
env: LARAVEL='5.8.*' TESTBENCH='3.8.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2
env: LARAVEL='6.*' TESTBENCH='4.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.2
env: LARAVEL='6.*' TESTBENCH='4.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.3
env: LARAVEL='6.*' TESTBENCH='4.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.3
env: LARAVEL='6.*' TESTBENCH='4.*' DBAL='2.9.*' COMPOSER_FLAGS='--prefer-stable'

before_install:
- phpenv config-rm xdebug.ini || true
- travis_retry composer self-update
- travis_retry composer require --no-update --no-interaction "illuminate/support=${LARAVEL}" "orchestra/testbench=${TESTBENCH}" "doctrine/dbal=${DBAL}"

install:
- travis_retry composer require "illuminate/support=${LARAVEL}" --dev --prefer-dist --no-interaction --no-suggest
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction --no-suggest

script: vendor/bin/phpunit --verbose
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased](https://github.com/cnvs/canvas/compare/master...develop)

## [4.2.8](https://github.com/cnvs/canvas/compare/v4.2.7...v4.2.8) (September 17, 2019)

## Added
- Added support for Laravel 6 LTS ([#549](https://github.com/cnvs/canvas/issues/549), [cd5fab3](https://github.com/cnvs/canvas/commit/cd5fab3b1ea1544e5256abd868fd09f88e8cff5a))

## Fixed
- Patch for an undefined 'host' index on referer links ([#545](https://github.com/cnvs/canvas/issues/545), [#546](https://github.com/cnvs/canvas/pull/546), [dfa09e3](https://github.com/cnvs/canvas/commit/dfa09e314a4ca45864dd96cd3353609a87d8ef2f))

## [4.2.7](https://github.com/cnvs/canvas/compare/v4.2.6...v4.2.7) (August 19, 2019)

## Added
Expand Down
101 changes: 51 additions & 50 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
{
"name": "cnvs/canvas",
"description": "A Laravel publishing platform",
"keywords": ["cnvs", "canvas", "laravel", "publishing"],
"license": "MIT",
"homepage": "https://cnvs.io",
"support": {
"issues": "https://github.com/cnvs/canvas/issues",
"source": "https://github.com/cnvs/canvas"
},
"authors": [
{
"name": "Todd Austin",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0",
"ext-json": "*",
"illuminate/support": "5.5.x|5.6.x|5.7.x|5.8.x"
},
"require-dev": {
"mockery/mockery": "^1.1",
"orchestra/testbench": "3.5.x|3.6.x|3.7.x|3.8.x",
"phpunit/phpunit": "^7.5"
},
"autoload": {
"psr-4": {
"Canvas\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Canvas\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"extra": {
"laravel": {
"providers": [
"Canvas\\CanvasServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
"name": "cnvs/canvas",
"description": "A Laravel publishing platform",
"keywords": ["canvas", "laravel", "publishing", "platform"],
"license": "MIT",
"homepage": "https://cnvs.io",
"support": {
"issues": "https://github.com/cnvs/canvas/issues",
"source": "https://github.com/cnvs/canvas"
},
"authors": [
{
"name": "Todd Austin",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.1",
"ext-json": "*",
"doctrine/dbal": "^2.6|^2.7|^2.8|^2.9",
"illuminate/support": "^5.6|^5.7|^5.8|^6.0"
},
"require-dev": {
"mockery/mockery": "^1.1",
"orchestra/testbench": "^3.6|^3.7|^3.8|^4.0",
"phpunit/phpunit": "^7.0|^8.0"
},
"autoload": {
"psr-4": {
"Canvas\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Canvas\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"extra": {
"laravel": {
"providers": [
"Canvas\\CanvasServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
13 changes: 12 additions & 1 deletion src/Listeners/StoreViewData.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function handle(PostViewed $event)
'post_id' => $event->post->id,
'ip' => request()->getClientIp(),
'agent' => request()->header('user_agent'),
'referer' => request()->header('referer'),
'referer' => $this->validUrl(request()->header('referer')),
];

$event->post->views()->create($view_data);
Expand Down Expand Up @@ -52,4 +52,15 @@ private function storeInSession(Post $post)
{
session()->put("viewed_posts.{$post->id}", time());
}

/**
* Return only value URLs.
*
* @param string $url
* @return mixed
*/
private function validUrl(string $url)
{
return filter_var($url, FILTER_VALIDATE_URL) ?? null;
}
}
2 changes: 1 addition & 1 deletion src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function getTopReferersAttribute(): array
// Filter the view data to only include referrers
$collection = collect();
$data->each(function ($item, $key) use ($collection) {
empty($item->referer) ? $collection->push(__('canvas::stats.details.referer.other')) : $collection->push(parse_url($item->referer)['host']);
empty(parse_url($item->referer)['host']) ? $collection->push(__('canvas::stats.details.referer.other')) : $collection->push(parse_url($item->referer)['host']);
});

// Count the unique values and assign to their respective keys
Expand Down
65 changes: 0 additions & 65 deletions tests/Helpers/SuffixedNumberTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Http/Middleware/ViewThrottleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Canvas\Tests\Listeners;
namespace Canvas\Tests\Middleware;

use Canvas\Post;
use Ramsey\Uuid\Uuid;
Expand Down
4 changes: 1 addition & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getPackageProviders($app): array
* @param Application $app
* @return void
*/
protected function resolveApplicationCore($app)
protected function resolveApplicationCore($app): void
{
parent::resolveApplicationCore($app);

Expand Down Expand Up @@ -75,8 +75,6 @@ protected function getEnvironmentSetUp($app): void
*/
protected function setUpDatabase($app): void
{
$this->loadLaravelMigrations();

$this->loadMigrationsFrom(dirname(__DIR__).'/database/migrations');

$this->artisan('migrate');
Expand Down

0 comments on commit 1b3ad47

Please sign in to comment.