...
 
Commits (13)
......@@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<style>
p {
p, li {
font-family: Roboto,Arial,sans-serif;
font-size: 18px;
line-height: 1.5;
......
......@@ -43,9 +43,12 @@ class content implements Interfaces\Api
}
$type = '';
$algorithm = strtolower($_GET['algorithm'] ?? 'top');
switch ($pages[1]) {
case 'activities':
$type = 'activity';
$algorithm = 'latest';
break;
case 'images':
$type = 'object:image';
......@@ -127,7 +130,7 @@ class content implements Interfaces\Api
'custom_type' => null,
'limit' => $limit,
'type' => $type,
'algorithm' => 'top',
'algorithm' => $algorithm,
'period' => '7d',
'sync' => $sync,
'from_timestamp' => $fromTimestamp,
......@@ -159,7 +162,7 @@ class content implements Interfaces\Api
try {
$result = $this->getData($entities, $opts, $asActivities, $sync);
if ($result->count() <= static::MIN_COUNT) {
if ($opts['algorithm'] !== 'latest' && $result->count() <= static::MIN_COUNT) {
$opts['algorithm'] = 'latest';
$result = $this->getData($entities, $opts, $asActivities, $sync);
}
......
......@@ -61,6 +61,12 @@ class wire implements Interfaces\Api
$recurring = isset($_POST['recurring']) ? $_POST['recurring'] : false;
$recurringInterval = $_POST['recurring_interval'] ?? 'once';
if ($recurring && $recurringInterval === 'once') {
$recurringInterval = 'monthly';
// Client side bug we need to track down, so lets log in Sentry
\Sentry\captureMessage("Recurring Subscription was created with 'once' interval");
}
if (!$amount) {
return Factory::response(['status' => 'error', 'message' => 'you must send an amount']);
}
......
Our team has been heads down in the lab developing open source technology that is changing the world. As always, our goal is to provide you with a platform that enables the free exchange of ideas, protects your digital rights and fairly compensates you for your contributions to the network.
Introducing Minds Pro (beta), a new revenue model for content creators.
- Get paid for your traffic and referrals
- Launch your own website
- Receive multi-currency tips and subscription payments from fans
- Supports video, images, blogs and more
| |
|:--:|
| [![Upgrade to Pro](https://cdn-assets.minds.com/emails/upgrade-to-pro.png){=150x}](https://www.minds.com/pro?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator'] ?>) |
| |
Thank you for your support!
......@@ -7,15 +7,52 @@
namespace Minds\Core;
use Minds\Core\Di\Di;
use Minds\Core\Features\Manager as Features;
use Minds\Core\Router\Dispatcher;
use Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\PrePsr7\Fallback;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Uri;
class Router
{
public function route($uri = null, $method = null, $host = null)
/** @var Dispatcher */
protected $dispatcher;
/** @var Features */
protected $features;
/** @var Fallback */
protected $fallback;
/**
* Router constructor.
* @param Dispatcher $dispatcher
* @param Features $features
* @param Fallback $fallback
*/
public function __construct(
$dispatcher = null,
$features = null,
$fallback = null
) {
$this->dispatcher = $dispatcher ?: Di::_()->get('Router');
$this->features = $features ?: Di::_()->get('Features');
$this->fallback = $fallback ?: new Fallback();
}
/**
* @param string|null $uri
* @param string|null $method
* @param string|null $host
*/
public function route(string $uri = null, string $method = null, string $host = null): void
{
if (!$this->features->has('psr7-router')) {
$this->fallback->route();
return;
}
if (!$uri) {
$uri = strtok($_SERVER['REDIRECT_ORIG_URI'] ?? $_SERVER['REQUEST_URI'], '?');
}
......@@ -28,9 +65,6 @@ class Router
$host = $_SERVER['HTTP_HOST'];
}
/** @var Dispatcher $dispatcher */
$dispatcher = Di::_()->get('Router');
$request = ServerRequestFactory::fromGlobals()
->withMethod($method)
->withUri(
......@@ -38,7 +72,7 @@ class Router
->withHost($host)
); // TODO: Ensure it works with reverse proxy
$response = $dispatcher
$response = $this->dispatcher
->pipe(new Kernel\ContentNegotiationMiddleware())
->pipe(new Kernel\ErrorHandlerMiddleware())
->pipe(
......
......@@ -14,6 +14,19 @@ use Psr\Http\Server\RequestHandlerInterface;
class Dispatcher implements RequestHandlerInterface
{
/** @var MiddlewareInterface */
protected $emptyResponseMiddleware;
/**
* Dispatcher constructor.
* @param MiddlewareInterface $emptyResponseMiddleware
*/
public function __construct(
$emptyResponseMiddleware = null
) {
$this->emptyResponseMiddleware = $emptyResponseMiddleware ?: new EmptyResponseMiddleware();
}
/** @var MiddlewareInterface[] */
protected $middleware = [];
......@@ -37,7 +50,7 @@ class Dispatcher implements RequestHandlerInterface
public function handle(ServerRequestInterface $request): ResponseInterface
{
if (count($this->middleware) === 0) {
return (new EmptyResponseMiddleware())->process($request, $this);
return $this->emptyResponseMiddleware->process($request, $this);
}
$middleware = array_shift($this->middleware);
......
......@@ -28,8 +28,7 @@ class SessionMiddleware implements MiddlewareInterface
*/
public function __construct(
$session = null
)
{
) {
$this->session = $session ?: Di::_()->get('Sessions\Manager');
}
......
......@@ -105,4 +105,12 @@ class Fallback
return new HtmlResponse($html, 200);
}
/**
* Complete routing fallback
*/
public function route()
{
(new Router())->route();
}
}
......@@ -89,6 +89,7 @@ class RegistryEntry
*/
public function matches(string $route): bool
{
$route = trim($route, '/');
$pattern = sprintf("#^%s$#i", strtr(preg_quote($this->getWildcardRoute(), '#'), ['\*' => '[^/]+']));
return (bool) preg_match($pattern, $route);
}
......
This diff is collapsed.
<?php
namespace Minds\Core\Security;
/**
* Domains listed here has been blacklisted due to spam.
* Short urls are also not allowed due to security issues.
*/
class ProhibitedDomains
{
/** @var array */
const DOMAINS = [
'movieblog.tumblr.com',
'moviehdstream.wordpress.com',
'moviehq.tumblr.com',
'moviehq.webs.com',
'moviehq.wordpress.com',
'movieo.wordpress.com',
'movieonline.tumblr.com',
'movieonline.webs.com',
'movieonline.wordpress.com',
'movieonlinehd.tumblr.com',
'movieonlinehd.webs.com',
'movieonlinehd.wordpress.com',
'movies.tumblr.com',
'moviesf.tumblr.com',
'moviesgodetia.com',
'movieslinks4u',
'moviesmount.com',
'moviesmonster.biz',
'moviesondesktop',
'moviesonlinefree.biz',
'moviestream.wordpress.com',
'movieontop.com',
'afllivestreaming.com.au',
'londonolympiccorner',
'nrllivestreaming.com.au',
'24x7livestreamtvchannels.com',
'www.edogo.us',
'all4health.in',
'watches4a.co.uk',
'es.jennyjoseph.com',
'allsportslive24x7.blogspot.com',
'boxing-tv-2014-live-stream.blogspot.com',
'amarblogdalima.blogspot.com',
'www.officialtvstream.com.es',
'topsalor.com',
'busybo.org',
'www.nowvideo.sx',
'180upload.com',
'allmyvideos.net',
'busybo.org',
'hdmovieshouse.biz',
'sportblog.info',
'psport.space',
'discus.space',
'euro2016.it.ua',
'neymar.space',
'espnstream.space',
'2016.vn.u',
'blogstream.space',
'liveextratime.xyz',
'thebestlive.xyz',
'streamoffside.xyz',
'sportmaster2014.page.tl',
'bloggersdelight.dk',
'watchsportslive.space',
'freeforward.xyz',
'live4sports.xyz',
'streamfun.xyz',
'angelfire.com',
'streamtime.xyz',
'futebol2star.com',
'live2sport.com',
'newssports.space',
'onlineolympics.xyz',
'liveolympics.xyz',
'streamontv.xyz',
'londonschedule.com',
'onlineolympics.space',
'sportwinning.xyz',
'streamworld.xyz',
'streamtop.xyz',
'livechampion.xyz',
'playstreams.xyz',
'live4sport.xyz',
'streampage.xyz',
'calendarsport.space',
'fsport.space',
'euro2016.od.ua',
'streambig.xyz',
'sportprediction.xyz',
'streamwork.xyz',
'r041.donnael.com',
'2016.lt.ua',
'vipleague.se',
'liveonline.company',
'liveolympics.space',
'seoandvideomarketing.com.au',
'vipbox.sx',
'germanypolandlivestream.club',
'sportgoal.xyz',
'ggdbsale.com',
'gorillasteroids.eu',
'watchlivesports.space',
'penaltyshootout.xyz',
'streamgroup.xyz',
'streamnew.xyz',
'cottonsport.space',
'gosport.space',
'streambest.xyz',
'penaltyspot.xyz',
'streamthe.xyz',
'liveevents.name',
'londonblog.work',
'testcollections.com',
'alfagy.com',
'teravide1974.full-design.com',
'selfnarhasbllaq1980-blog.logdown.com',
'neipononchoi1984.suomiblog.com',
'gemttranlonthe1985.blogzet.com',
'pitchero.com',
'blogolize.com',
'lisbopholsven1974.thezenweb.com',
'blogocial.com',
'tinyblogging.com',
'share.pho.to',
'community.vietfun.com',
'ockuderla1985.full-design.com',
'unmosimla1978.total-blog.com',
'gemttranlonthe1985.blogzet.com',
'rapptubizboe1978.blogminds.com',
'descduclighgon1973.full-design.com',
'ricphosati1972.full-design.com',
'fuddbluslanmaa1975.blogdigy.com',
'smarforcute1976.blogdigy.com',
'xn--90aizihgi.xn--p1ai',
'tinyurl.com',
'bit.ly',
'bit.do',
'123football.space',
'bitly.com',
'j.mp',
'livestreaming.one',
'livestreaming.life',
'forbest.pw',
'olizev.tdska2ll.ru',
'tdska2ll.ru',
'tdska1ll.ru',
'tdska3ll.ru',
'tdska4ll.ru',
'ihmail.ru',
'tdska5ll.ru',
'tdska6ll.ru',
'll.ru',
'shorl.com',
'scorestream.space',
'bestsplayer.xyz',
'worldwideevents.space',
'worldseries.space',
'best247chemist.net',
'9tn.ru',
'futbolkin2013.ru',
'playnowstore.com',
'qr-url.tk',
'watchonlinerugby.net',
'esecuritys.com',
'rufile.no-ip.ca',
'imzonline.com',
'femeedia.com',
'mediomatic.com',
'savemoneyeasily.com',
'option1pro.com',
'perron07.nl',
'movieonrails.com',
'topmoviestoday.com',
'playnowstore.com',
'g-files.biz',
'dawnloadonline.com',
'thedirsite.com',
'siteslocate.com',
'mydrugdir.com',
'find24hs.com',
'veeble.org',
'movieonrails.com',
'bestmoviehd.net',
'putmovies.info',
'awarefinance.com',
'shurll.com',
'acceptsearch.com',
'signforcover.com',
'raisengine.com',
'rocketcarrental.com',
'godsearchs.com',
'listenhanced.com',
'find24hs.com',
'findinform.com',
'sitesworlds.com',
'rocketcarrental.com',
'thedirsite.com',
'getboook.com',
'pokerarena88.com',
'aquamelia.com',
'beautyskintalks.com',
'getmooovie.com',
'getdriversss.com',
'getsoooft.com',
'getgamesss.com',
'abrts.pro',
'leadbit.biz',
'efght.pro',
'qyresearcheurope.com',
'plusfreemaxfr.com',
'getappmac.com',
'getharlemhealthy.org',
'goo.gl',
'getmooovie.com',
'marketreportscenter.com',
'getsooft.com',
'myowndom.ru',
'print-mgn.ru',
'wiki-data.ru',
'velobog.ru',
'mobisony.ru',
'dzeroki.ru',
'slimkor.ru',
'kak-brosit-kyrit.ru',
'jinyurl.com',
'urlin.us',
'capillus.com',
'siteprofissional.com',
'mitersawjudge.com',
'mohajreen-jeeda.com',
'jobberies.com',
'bestfilms.site',
'baystudios.ch',
'elvenarhack.bid',
'essencephskincare.com',
'blog2learn.com',
'superrugbyonline.net',
'superrugby18.livejournal.com',
'expertairco.com',
'draesthetica.co.uk',
'sphere.social',
'saveabookmarks.xyz',
'/t.co',
'samuelsconstruction.build',
'pmwares.com',
'watchesofwales.co.uk',
'zotero.org',
'speakerdeck.com',
'freesiteslike.com',
'pusha.se',
'vrootdownload.org',
'rubberwebshop.nl',
'restaurerlecorps.info',
'discretthemes.info',
'bride-forever.com',
'simplesmetamorphoses.info',
'mp3gain.com',
'mp4gain.com',
'ttlink.com',
'onepost.cf',
'getmefunds.com',
'vikinail.pl',
'typesofbeauty.info',
'joie6portia93.bloglove.cc',
'htgtea.com',
'tblogz.com',
'liveinternet.ru',
'.diowebhost.com',
'/yoursite.com',
'reworkedgames.eu',
'mp3gain.sourceforge.net',
'pages10.com',
'nudegirIs.info',
'aidagirls.com',
'alsoloves.com',
'hotswishes.com',
'instaphoto.club',
'intimspace.com',
'pornopoisk.info',
'localmodels.online',
'kaikki-mallit.com',
'hotswishes.com',
];
}
This diff is collapsed.
......@@ -90,4 +90,26 @@ class Text
{
return (string) $value;
}
/**
* Runs through a body of text, checking it for values.
*
* @param [type] $haystack - Body of text.
* @param [type] $needles - Array of values to be searched for.
* @param integer $offset - offset to start.
* @return boolean|string - The matching value.
*/
public static function strposa($haystack, $needles, $offset = 0)
{
if (!is_array($needles)) {
$needles = [$needles];
}
foreach ($needles as $query) {
if (stripos($haystack, $query, $offset) !== false) {
// stop on first true result
return $query;
}
}
return false;
}
}
......@@ -275,28 +275,26 @@ class ManagerSpec extends ObjectBehavior
->shouldReturn(true);
}
public function it_should_abort_if_spam(Blog $blog)
public function it_should_check_for_spam(Blog $blog, Spam $spam)
{
$this->beConstructedWith(
$this->repository,
$this->paywallReview,
$this->slug,
$this->feeds,
null,
$this->spam,
$this->search
);
$spamUrl = 'movieblog.tumblr.com';
$blog->getType()
->willReturn('object');
->willReturn('object');
$blog->getSubtype()
->willReturn('blog');
$blog->getBody()
->shouldBeCalled()
->willReturn('movieblog.tumblr.com');
->willReturn('blog');
$this->shouldThrow(new \Exception('Sorry, you included a reference to a domain name linked to spam. You can not use short urls (eg. bit.ly). Please remove it and try again'))
->duringAdd($blog);
$this->spam->check(Argument::any())->shouldBeCalled()->willReturn(true);
$this->add($blog);
}
}
<?php
namespace Spec\Minds\Core\Router;
use Minds\Core\Router\Dispatcher;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
class DispatcherSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(Dispatcher::class);
}
public function it_should_pipe(
MiddlewareInterface $middleware
) {
$this
->pipe($middleware)
->shouldReturn($this);
}
public function it_should_handle(
MiddlewareInterface $middleware1,
MiddlewareInterface $middleware2,
ServerRequestInterface $request,
ResponseInterface $response
) {
$middleware1->process($request, $this)
->shouldBeCalled()
->willReturn($response);
$middleware2->process(Argument::cetera())
->shouldNotBeCalled();
$this
->pipe($middleware1)
->pipe($middleware2)
->handle($request)
->shouldReturn($response);
}
public function it_should_handle_an_empty_stack(
MiddlewareInterface $fallbackMiddleware,
ServerRequestInterface $request,
ResponseInterface $response
) {
$this->beConstructedWith($fallbackMiddleware);
$fallbackMiddleware->process($request, $this)
->shouldBeCalled()
->willReturn($response);
$this
->handle($request)
->shouldReturn($response);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware;
use Minds\Core\Router\Middleware\AdminMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class AdminMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(AdminMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\ContentNegotiationMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ContentNegotiationMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(ContentNegotiationMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\CorsMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class CorsMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(CorsMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\EmptyResponseMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class EmptyResponseMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(EmptyResponseMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\ErrorHandlerMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ErrorHandlerMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(ErrorHandlerMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\FrameSecurityMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class FrameSecurityMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(FrameSecurityMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\JsonPayloadMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class JsonPayloadMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(JsonPayloadMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\OauthMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class OauthMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(OauthMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\RegistryEntryMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RegistryEntryMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(RegistryEntryMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\RequestHandlerMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RequestHandlerMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(RequestHandlerMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\RouteResolverMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RouteResolverMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(RouteResolverMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\SessionMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class SessionMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(SessionMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware\Kernel;
use Minds\Core\Router\Middleware\Kernel\XsrfCookieMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class XsrfCookieMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(XsrfCookieMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\Middleware;
use Minds\Core\Router\Middleware\LoggedInMiddleware;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class LoggedInMiddlewareSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(LoggedInMiddleware::class);
}
}
<?php
namespace Spec\Minds\Core\Router\PrePsr7;
use Minds\Core\Router\PrePsr7\Fallback;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class FallbackSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(Fallback::class);
}
}
<?php
namespace Spec\Minds\Core\Router;
use Minds\Core\Router\RegistryEntry;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RegistryEntrySpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(RegistryEntry::class);
}
public function it_should_set_route()
{
$this
->setRoute('/phpspec/:id/edit/')
->getRoute()
->shouldReturn('phpspec/:id/edit');
}
public function it_should_get_wildcard_route()
{
$this
->setRoute('/phpspec/:id/edit/')
->getWildcardRoute()
->shouldReturn('phpspec/*/edit');
}
public function it_should_get_depth()
{
$this
->setRoute('/')
->getDepth()
->shouldReturn(-1);
$this
->setRoute('/phpspec')
->getDepth()
->shouldReturn(0);
$this
->setRoute('/phpspec/:id/edit/')
->getDepth()
->shouldReturn(2);
}
public function it_should_get_specificity()
{
$this
->setRoute('/')
->getSpecificity()
->shouldReturn(1);
$this
->setRoute('/phpspec')
->getSpecificity()
->shouldReturn(1);
$this
->setRoute('/phpspec/:id/edit/')
->getSpecificity()
->shouldReturn(5);
$this
->setRoute('/phpspec/random/edit')
->getSpecificity()
->shouldReturn(7);
}
public function it_should_match()
{
$this
->setRoute('/')
->matches('/')
->shouldReturn(true);
$this
->setRoute('/')
->matches('/test')
->shouldReturn(false);
$this
->setRoute('/phpspec/:id')
->matches('/phpspec/1000')
->shouldReturn(true);
$this
->setRoute('/phpspec/:id')
->matches('/phpspec')
->shouldReturn(false);
$this
->setRoute('/phpspec/:id')
->matches('/phpspec/9999/1000')
->shouldReturn(false);
$this
->setRoute('/phpspec/:id/edit')
->matches('/phpspec/1000/edit')
->shouldReturn(true);
$this
->setRoute('/phpspec/:id/edit')
->matches('/phpspec/1000')
->shouldReturn(false);
$this
->setRoute('/phpspec/:id/edit')
->matches('/phpspec/9999/1000')
->shouldReturn(false);
}
public function it_should_extract()
{
$this
->setRoute('/phpspec/:id/edit')
->extract('/phpspec/9999/edit')
->shouldReturn(['id' => '9999']);
$this
->setRoute('/phpspec/:id/edit/:timestamp')
->extract('/phpspec/9999/edit/1000000')
->shouldReturn(['id' => '9999', 'timestamp' => '1000000']);
}
}
<?php
namespace Spec\Minds\Core\Router;
use Minds\Core\Router\Registry;
use Minds\Core\Router\RegistryEntry;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Server\MiddlewareInterface;
class RegistrySpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(Registry::class);
}
public function it_should_register(
MiddlewareInterface $middleware
) {
$this
->register('post', '/phpspec', function () {
}, [$middleware])
->shouldReturn($this);
}
public function it_should_get_best_match(
MiddlewareInterface $middleware
) {
$this
->register('get', '/phpspec/:id', null, [$middleware])
->register('get', '/phpspec/new', null, [$middleware])
->register('get', '/phpspec/', null, [$middleware])
->getBestMatch('get', '/phpspec/new')
->shouldBeARegistryEntryWithRoute('phpspec/new');
}
public function getMatchers(): array
{
return [
'beARegistryEntryWithRoute' => function ($subject, $route) {
if (!($subject instanceof RegistryEntry)) {
throw new FailureException(sprintf("%s is a RegistryEntry instance", get_class($subject)));
}
if ($subject->getRoute() !== $route) {
throw new FailureException(sprintf("[RegistryEntry:%s] routes to %s", $subject->getRoute(), $route));
}
return true;
}
];
}
}
<?php
namespace Spec\Minds\Core\Router;
use Minds\Core\Router\Route;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RouteSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(Route::class);
}
}
<?php
namespace Spec\Minds\Core;
use Minds\Core\Router;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RouterSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType(Router::class);
}
}
<?php
namespace Spec\Minds\Core\Security;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Minds\Core\Blogs\Blog;
use Minds\Core\Config;
use Minds\Core\Comments\Comment;
use Minds\Entities\User;
use Minds\Entities\Group;
use Minds\Entities\Entity;
use Minds\Core\Security\ProhibitedDomains;
class SpamSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->shouldHaveType('Minds\Core\Security\Spam');
}
public function it_should_detect_spam_in_a_blog(
Blog $blog,
ProhibitedDomains $prohibitedDomains
) {
$blog->getBody()->shouldBeCalled()->willReturn('test bit.ly test');
$blog->getType()->shouldBeCalled()->willReturn('object');
$blog->getSubtype()->shouldBeCalled()->willReturn('blog');
$this->shouldThrow(new \Exception("Sorry, you included a reference to a domain name linked to spam (bit.ly)"))
->duringCheck($blog);
}
public function it_should_detect_spam_in_a_comment(
Comment $comment,
ProhibitedDomains $prohibitedDomains
) {
$comment = new Comment();
$comment->setBody('test bit.ly test');
$comment->setType('comment');
$this->shouldThrow(new \Exception("Sorry, you included a reference to a domain name linked to spam (bit.ly)"))
->duringCheck($comment);
}
public function it_should_detect_spam_in_a_user(
User $user,
ProhibitedDomains $prohibitedDomains
) {
$user = new User('123');
$user['briefdescription'] = 'test bit.ly test';
$user['type'] = 'user';
$this->shouldThrow(new \Exception("Sorry, you included a reference to a domain name linked to spam (bit.ly)"))
->duringCheck($user);
}
public function it_should_detect_spam_in_a_group(
Group $group,
ProhibitedDomains $prohibitedDomains
) {
$group = new Group();
$group->setBriefdescription('test bit.ly test');
$group->setType('group');
$this->shouldThrow(new \Exception("Sorry, you included a reference to a domain name linked to spam (bit.ly)"))
->duringCheck($group);
}
public function it_should_detect_NO_spam_in_a_blog(
Blog $blog,
ProhibitedDomains $prohibitedDomains
) {
$blog->getBody()->shouldBeCalled()->willReturn('test bit.nospam test');
$blog->getType()->shouldBeCalled()->willReturn('object');
$blog->getSubtype()->shouldBeCalled()->willReturn('blog');
$this->check($blog)->shouldReturn(false);
}
public function it_should_detect_NO_spam_in_a_comment(
Comment $comment,
ProhibitedDomains $prohibitedDomains
) {
$comment = new Comment();
$comment->setBody('test bit.nospam test');
$comment->setType('comment');
$this->check($comment)->shouldReturn(false);
}
public function it_should_detect_NO_spam_in_a_user(
User $user,
ProhibitedDomains $prohibitedDomains
) {
$user = new User('123');
$user['briefdescription'] = 'test bit.nospam test';
$user['type'] = 'user';
$this->check($user)->shouldReturn(false);
}
public function it_should_detect_NO_spam_in_a_group(
Group $group,
ProhibitedDomains $prohibitedDomains
) {
$group = new Group();
$group->setBriefdescription('test bit.nospam test');
$group->setType('group');
$this->check($group)->shouldReturn(false);
}
}
......@@ -12,6 +12,7 @@ RUN apk add --no-cache --virtual build-deps \
coreutils \
imagemagick \
nodejs \
npm \
ffmpeg \
&& docker-php-ext-install -j$(nproc) bcmath \
&& docker-php-ext-install -j$(nproc) zip \
......
......@@ -472,6 +472,7 @@ $CONFIG->set('max_video_length', 900);
$CONFIG->set('max_video_length_plus', 1860);
$CONFIG->set('features', [
'psr7-router' => true,
'es-feeds' => false,
'helpdesk' => true,
'top-feeds' => true,
......