mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge branch '2.1' into 2
This commit is contained in:
commit
62057bf7e3
48
.travis.yml
48
.travis.yml
@ -1,56 +1,32 @@
|
||||
language: php
|
||||
|
||||
sudo: true
|
||||
dist: trusty
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- tidy
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
before_install:
|
||||
- pip install --user codecov
|
||||
|
||||
env:
|
||||
global:
|
||||
- DB=MYSQL CORE_RELEASE=3.5
|
||||
- MODULE_PATH=comments
|
||||
|
||||
# Set to 1 in the matrix to enable code coverage
|
||||
- COVERAGE=0
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
#CommentsListTest breaks with this env: DB=MYSQL CORE_RELEASE=3.2 COVERAGE=1
|
||||
env: DB=SQLITE CORE_RELEASE=3.5 COVERAGE=1
|
||||
- php: 7.1
|
||||
- php: '5.6'
|
||||
env: DB=MYSQL CORE_RELEASE=3.6
|
||||
- php: 5.6
|
||||
env: DB=PGSQL CORE_RELEASE=3.5
|
||||
- php: 7.1
|
||||
env: DB=MYSQL CORE_RELEASE=3
|
||||
- php: '7.0'
|
||||
env: DB=MYSQL CORE_RELEASE=3.7
|
||||
- php: '7.1'
|
||||
env: DB=PGSQL CORE_RELEASE=3.7
|
||||
- php: '7.2'
|
||||
env: DB=MYSQL CORE_RELEASE=3.7
|
||||
- php: '7.3'
|
||||
env: DB=MYSQL CORE_RELEASE=3.7
|
||||
|
||||
before_script:
|
||||
- phpenv rehash
|
||||
- composer self-update || true
|
||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
||||
# Install suggested modules in order to maximize test coverage
|
||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require "ezyang/htmlpurifier:4.*,silverstripe/cms:~3.1"
|
||||
- cd ~/builds/ss
|
||||
|
||||
script:
|
||||
# Execute tests with no coverage. This is the fastest option
|
||||
- "if [ \"$COVERAGE\" = \"0\" ]; then vendor/bin/phpunit $MODULE_PATH/tests/; fi"
|
||||
|
||||
# Execute tests with coverage. Do this for a small
|
||||
- "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.clover $MODULE_PATH/tests/; fi"
|
||||
|
||||
after_script:
|
||||
- "if [ \"$COVERAGE\" = \"1\" ]; then mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/; fi"
|
||||
- cd ~/build/$TRAVIS_REPO_SLUG
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- "if [ \"$COVERAGE\" = \"1\" ]; then travis_retry codecov && travis_retry php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi"
|
||||
- vendor/bin/phpunit comments/tests
|
||||
|
@ -649,8 +649,10 @@ class Comment extends DataObject
|
||||
*/
|
||||
public function purifyHtml($dirtyHtml)
|
||||
{
|
||||
$purifier = $this->getHtmlPurifierService();
|
||||
return $purifier->purify($dirtyHtml);
|
||||
if ($service = $this->getHtmlPurifierService()) {
|
||||
return $service->purify($dirtyHtml);
|
||||
}
|
||||
return $dirtyHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,6 +660,10 @@ class Comment extends DataObject
|
||||
*/
|
||||
public function getHtmlPurifierService()
|
||||
{
|
||||
if (!class_exists('HTMLPurifier_Config')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$allowedElements = $this->getOption('html_allowed_elements');
|
||||
$config->set('HTML.AllowedElements', $allowedElements);
|
||||
|
@ -22,7 +22,7 @@
|
||||
"silverstripe/cms": "The SilverStripe Content Management System"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/PHPUnit": "~3.7@stable"
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -168,8 +168,8 @@
|
||||
comment.fadeOut(1000, function() {
|
||||
comment.remove();
|
||||
|
||||
if(commentsList.children().length === 0) {
|
||||
noCommentsYet.show();
|
||||
if($('.comments-holder .comments-list').children().length === 0) {
|
||||
$('.no-comments-yet').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -974,6 +974,11 @@ class CommentsTest extends FunctionalTest
|
||||
|
||||
public function testPurifyHtml()
|
||||
{
|
||||
if (!class_exists('HTMLPurifier_Config')) {
|
||||
$this->markTestSkipped('HTMLPurifier class not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$comment = $this->objFromFixture('Comment', 'firstComA');
|
||||
|
||||
$dirtyHTML = '<p><script>alert("w00t")</script>my comment</p>';
|
||||
|
Loading…
Reference in New Issue
Block a user