Merge branch 'master' into JSnotWorkingError
This commit is contained in:
commit
70482a4fc0
40 changed files with 496 additions and 468 deletions
|
@ -38,6 +38,6 @@ indent_style = space
|
|||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[.travis.yml]
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
|
|
6
.php_cs
6
.php_cs
|
@ -15,9 +15,9 @@ return Symfony\CS\Config\Config::create()
|
|||
->fixers(['concat_with_spaces', 'long_array_syntax', 'standardize_not_equal',
|
||||
'operators_spaces', 'duplicate_semicolon',
|
||||
'remove_leading_slash_use', 'align_equals',
|
||||
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_scalar',
|
||||
'phpdoc_to_comment', 'phpdoc_trim',
|
||||
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_order',
|
||||
'phpdoc_scalar', 'phpdoc_to_comment', 'phpdoc_trim',
|
||||
'phpdoc_types', 'print_to_echo', 'self_accessor', 'single_quote',
|
||||
'spaces_cast', 'ternary_spaces', 'phpdoc_order'])
|
||||
'spaces_cast', 'ternary_spaces'])
|
||||
->finder($finder)
|
||||
;
|
||||
|
|
26
.styleci.yml
Normal file
26
.styleci.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
preset: recommended
|
||||
|
||||
risky: false
|
||||
|
||||
enabled:
|
||||
- no_empty_comment
|
||||
- align_equals
|
||||
- long_array_syntax
|
||||
- concat_with_spaces
|
||||
|
||||
disabled:
|
||||
- blank_line_after_opening_tag
|
||||
- blank_line_before_return
|
||||
- concat_without_spaces
|
||||
- declare_equal_normalize
|
||||
- heredoc_to_nowdoc
|
||||
- method_argument_space
|
||||
- new_with_braces
|
||||
- phpdoc_align
|
||||
- phpdoc_no_access
|
||||
- phpdoc_separation
|
||||
- phpdoc_single_line_var_spacing
|
||||
- phpdoc_summary
|
||||
- short_array_syntax
|
||||
- single_line_after_imports
|
||||
- unalign_equals
|
|
@ -1,5 +1,9 @@
|
|||
# PrivateBin version history
|
||||
|
||||
* **next (not yet released)**
|
||||
* ADDED: Translations for Italian
|
||||
* CHANGED: Suppressed referrer HTTP header sending when following links in a paste or comment (#96) and added additional HTTP headers for XSS mitigation (#91)
|
||||
* CHANGED: Updated random_compat and jQuery libraries
|
||||
* **1.0 (2016-08-25)**
|
||||
* ADDED: Translations for Slowene and Chinese
|
||||
* ADDED: re-introduced (optional) URL shortener support, which was removed back in version 0.16 for privacy concerns
|
||||
|
|
|
@ -19,6 +19,7 @@ Sébastien Sauvage - original idea and main developer
|
|||
* Adam Fisher - old Favicons
|
||||
* rugk - new logo/icons
|
||||
* Sobak - PSR-4 and PSR-2 refactoring
|
||||
* Nathaniel Olsen - jQuery upgrade
|
||||
|
||||
## Translations
|
||||
* Hexalyse - French
|
||||
|
@ -27,3 +28,4 @@ Sébastien Sauvage - original idea and main developer
|
|||
* Draky50110 - French
|
||||
* Filip Muki Dobranić - Slovene
|
||||
* Jiawei Zhou - Chinese
|
||||
* Stefano Marty - Italian
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\I18n;
|
||||
use Exception;
|
||||
use PDO;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
use stdClass;
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
use PrivateBin\PrivateBin;
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PrivateBin\PrivateBin;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
use PrivateBin\Model\Paste;
|
||||
use PrivateBin\Json;
|
||||
use PrivateBin\Model\Paste;
|
||||
|
||||
/**
|
||||
* Filesystem
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\I18n;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
/**
|
||||
|
@ -296,12 +295,12 @@ class I18n
|
|||
switch (self::$_language) {
|
||||
case 'fr':
|
||||
case 'zh':
|
||||
return ($n > 1 ? 1 : 0);
|
||||
return $n > 1 ? 1 : 0;
|
||||
case 'pl':
|
||||
return ($n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2;
|
||||
// en, de
|
||||
default:
|
||||
return ($n != 1 ? 1 : 0);
|
||||
return $n != 1 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\Data;
|
||||
use PrivateBin\Model\Paste;
|
||||
use PrivateBin\Persistence\PurgeLimiter;
|
||||
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use Exception;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\AbstractData;
|
||||
use PrivateBin\Sjcl;
|
||||
use Exception;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use PrivateBin\Sjcl;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
use Identicon\Identicon;
|
||||
use Exception;
|
||||
use Identicon\Identicon;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Sjcl;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
|
||||
/**
|
||||
* Comment
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Sjcl;
|
||||
use Exception;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Sjcl;
|
||||
|
||||
/**
|
||||
* Paste
|
||||
|
@ -307,7 +306,6 @@ class Paste extends AbstractModel
|
|||
$this->_data->meta->burnafterreading === true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if paste has discussions enabled.
|
||||
*
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
use PrivateBin\Configuration;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
use PrivateBin\Configuration;
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use Exception;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
|
||||
/**
|
||||
* PrivateBin
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@ class Sjcl
|
|||
*/
|
||||
public static function isValid($encoded)
|
||||
{
|
||||
$accepted_keys = array('iv','v','iter','ks','ts','mode','adata','cipher','salt','ct');
|
||||
$accepted_keys = array('iv', 'v', 'iter', 'ks', 'ts', 'mode', 'adata', 'cipher', 'salt', 'ct');
|
||||
|
||||
// Make sure content is valid json
|
||||
$decoded = json_decode($encoded);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 0.0.5 beta PrivateBin 1.0
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +22,6 @@ namespace PrivateBin;
|
|||
* echo $data;
|
||||
* exit;
|
||||
*/
|
||||
|
||||
class Vizhash16x16
|
||||
{
|
||||
/**
|
||||
|
@ -105,7 +103,7 @@ class Vizhash16x16
|
|||
$op = 'v';
|
||||
if (($this->getInt() % 2) == 0) {
|
||||
$op = 'h';
|
||||
};
|
||||
}
|
||||
$image = $this->degrade($image, $op, array($r0, $g0, $b0), array(0, 0, 0));
|
||||
|
||||
for ($i = 0; $i < 7; ++$i) {
|
||||
|
@ -189,7 +187,7 @@ class Vizhash16x16
|
|||
$diffs = array(
|
||||
(($color2[0] - $color1[0]) / $size),
|
||||
(($color2[1] - $color1[1]) / $size),
|
||||
(($color2[2] - $color1[2]) / $size)
|
||||
(($color2[2] - $color1[2]) / $size),
|
||||
);
|
||||
for ($i = 0; $i < $size; ++$i) {
|
||||
$r = $color1[0] + ($diffs[0] * $i);
|
||||
|
@ -217,20 +215,20 @@ class Vizhash16x16
|
|||
{
|
||||
switch ($action % 7) {
|
||||
case 0:
|
||||
ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
imagefilledrectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
imagefilledellipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
break;
|
||||
case 3:
|
||||
$points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY());
|
||||
ImageFilledPolygon($image, $points, 4, $color);
|
||||
imagefilledpolygon($image, $points, 4, $color);
|
||||
break;
|
||||
default:
|
||||
$start = $this->getInt() * 360 / 256;
|
||||
$end = $start + $this->getInt() * 180 / 256;
|
||||
ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
|
||||
imagefilledarc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* DANGER: Too many options/settings and too high max iteration setting may trigger
|
||||
* a fork bomb. Please save your work before executing this script.
|
||||
*/
|
||||
|
||||
include 'Bootstrap.php';
|
||||
|
||||
$vrd = array('view', 'read', 'delete');
|
||||
|
@ -26,7 +25,7 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<div[^>]*id="opendisc"[^>]*>#',
|
||||
'$content',
|
||||
'outputs enabled discussion correctly'
|
||||
'outputs enabled discussion correctly',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
|
||||
|
@ -35,7 +34,7 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when discussions are enabled, but invalid flag posted, fail to create paste'
|
||||
'when discussions are enabled, but invalid flag posted, fail to create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
|
||||
|
@ -43,11 +42,11 @@ new ConfigurationTestGenerator(array(
|
|||
'type' => 'False',
|
||||
'args' => array(
|
||||
'$this->_model->exists(Helper::getPasteId())',
|
||||
'when discussions are enabled, but invalid flag posted, paste is not created'
|
||||
'when discussions are enabled, but invalid flag posted, paste is not created',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vcud
|
||||
'affects' => $vcud,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
|
@ -56,11 +55,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<div[^>]*id="opendisc"[^>]*>#',
|
||||
'$content',
|
||||
'outputs disabled discussion correctly'
|
||||
'outputs disabled discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/opendiscussion' => array(
|
||||
|
@ -73,11 +72,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
'$content',
|
||||
'outputs checked discussion correctly'
|
||||
'outputs checked discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
|
@ -87,11 +86,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
'$content',
|
||||
'outputs unchecked discussion correctly'
|
||||
'outputs unchecked discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/burnafterreadingselected' => array(
|
||||
|
@ -132,11 +131,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<div[^>]*id="password"[^>]*>#',
|
||||
'$content',
|
||||
'outputs password input correctly'
|
||||
'outputs password input correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
|
@ -146,11 +145,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
'#<div[^>]*id="password"[^>]*>#',
|
||||
'$content',
|
||||
'removes password input correctly'
|
||||
'removes password input correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/template' => array(
|
||||
|
@ -206,11 +205,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when sizelimit limit exceeded, fail to create paste'
|
||||
'when sizelimit limit exceeded, fail to create paste',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 2097152,
|
||||
'tests' => array(
|
||||
|
@ -221,7 +220,7 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when sizelimit limit is not reached, successfully create paste'
|
||||
'when sizelimit limit is not reached, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true),
|
||||
|
@ -229,11 +228,11 @@ new ConfigurationTestGenerator(array(
|
|||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when sizelimit limit is not reached, paste exists after posting data'
|
||||
'when sizelimit limit is not reached, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
),
|
||||
),
|
||||
'traffic/limit' => array(
|
||||
|
@ -246,18 +245,18 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when traffic limit is disabled, successfully create paste'
|
||||
'when traffic limit is disabled, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when traffic limit is disabled, paste exists after posting data'
|
||||
'when traffic limit is disabled, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 10,
|
||||
'tests' => array(
|
||||
|
@ -267,11 +266,11 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when traffic limit is on and we do not wait, fail to create paste'
|
||||
'when traffic limit is on and we do not wait, fail to create paste',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 2,
|
||||
'tests' => array(
|
||||
|
@ -282,7 +281,7 @@ new ConfigurationTestGenerator(array(
|
|||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when traffic limit is on and we wait, successfully create paste'
|
||||
'when traffic limit is on and we wait, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
|
@ -290,11 +289,11 @@ new ConfigurationTestGenerator(array(
|
|||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when traffic limit is on and we wait, paste exists after posting data'
|
||||
'when traffic limit is on and we wait, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -325,7 +324,7 @@ class ConfigurationTestGenerator
|
|||
* @var array
|
||||
*/
|
||||
private $_configurations = array(
|
||||
array('options' => array(), 'tests' => array(), 'affects' => array())
|
||||
array('options' => array(), 'tests' => array(), 'affects' => array()),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -470,7 +469,7 @@ EOT;
|
|||
private function _getFunction($step, $key, &$options, $preCode, $testCode)
|
||||
{
|
||||
if (count($testCode) == 0) {
|
||||
echo "skipping creation of test$step$key, no valid tests found for configuration: $options". PHP_EOL;
|
||||
echo "skipping creation of test$step$key, no valid tests found for configuration: $options" . PHP_EOL;
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
public function testGetFooInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,9 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
mkdir($this->_path);
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'attachement-test.sq3';
|
||||
if (is_file($path)) unlink($path);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'bar_';
|
||||
$model = Database::getInstance($this->_options);
|
||||
|
@ -274,7 +276,9 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
mkdir($this->_path);
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'db-test.sq3';
|
||||
if (is_file($path)) unlink($path);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'foo_';
|
||||
$db = new PDO(
|
||||
|
@ -294,13 +298,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
);
|
||||
$db->exec(
|
||||
'CREATE TABLE foo_comment ( ' .
|
||||
"dataid CHAR(16) NOT NULL, " .
|
||||
'dataid CHAR(16) NOT NULL, ' .
|
||||
'pasteid CHAR(16), ' .
|
||||
'parentid CHAR(16), ' .
|
||||
'data BLOB, ' .
|
||||
'nickname BLOB, ' .
|
||||
'vizhash BLOB, ' .
|
||||
"postdate INT );"
|
||||
'postdate INT );'
|
||||
);
|
||||
$this->assertInstanceOf(Database::class, Database::getInstance($this->_options));
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Request;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
|
||||
class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Identicon\Identicon;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\Model;
|
||||
|
@ -7,7 +8,6 @@ use PrivateBin\Model\Paste;
|
|||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
use Identicon\Identicon;
|
||||
|
||||
class ModelTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -22,7 +22,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
|||
/* Setup Routine */
|
||||
Helper::confRestore();
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
if (!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
ServerSalt::setPath($this->_path);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['limit'] = 0;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\PrivateBin;
|
||||
|
||||
class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
|
||||
require_once 'PrivateBinTest.php';
|
||||
|
||||
|
@ -14,7 +12,7 @@ class PrivateBinWithDbTest extends PrivateBinTest
|
|||
'pwd' => null,
|
||||
'opt' => array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_PERSISTENT => true
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ Running unit tests
|
|||
In order to run these tests, you will need to install the following packages
|
||||
and its dependencies:
|
||||
* phpunit
|
||||
* php5-gd
|
||||
* php5-sqlite
|
||||
* php5-xdebug
|
||||
* php-gd
|
||||
* php-sqlite
|
||||
* php-xdebug
|
||||
|
||||
Example for Debian and Ubuntu:
|
||||
```sh
|
||||
$ sudo aptitude install phpunit php5-gd php5-sqlite php5-xdebug
|
||||
$ sudo aptitude install phpunit php-gd php-sqlite php-xdebug
|
||||
```
|
||||
|
||||
To run the tests, just change into this directory and run phpunit:
|
||||
|
|
30
vendor/paragonie/random_compat/lib/random.php
vendored
30
vendor/paragonie/random_compat/lib/random.php
vendored
|
@ -3,8 +3,8 @@
|
|||
* Random_* Compatibility Library
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* @version 2.0.2
|
||||
* @released 2016-04-03
|
||||
* @version 2.0.4
|
||||
* @released 2016-11-07
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
@ -41,8 +41,10 @@ if (!defined('PHP_VERSION_ID')) {
|
|||
$RandomCompatversion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP 7.0.0 and newer have these functions natively.
|
||||
*/
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
|
||||
if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
|
||||
define('RANDOM_COMPAT_READ_BUFFER', 8);
|
||||
}
|
||||
|
@ -67,7 +69,7 @@ if (PHP_VERSION_ID < 70000) {
|
|||
* 4. COM('CAPICOM.Utilities.1')->GetRandom()
|
||||
* 5. openssl_random_pseudo_bytes() (absolute last resort)
|
||||
*
|
||||
* See ERRATA.md for our reasoning behind this particular order
|
||||
* See RATIONALE.md for our reasoning behind this particular order
|
||||
*/
|
||||
if (extension_loaded('libsodium')) {
|
||||
// See random_bytes_libsodium.php
|
||||
|
@ -123,6 +125,20 @@ if (PHP_VERSION_ID < 70000) {
|
|||
|
||||
/**
|
||||
* mcrypt_create_iv()
|
||||
*
|
||||
* We only want to use mcypt_create_iv() if:
|
||||
*
|
||||
* - random_bytes() hasn't already been defined
|
||||
* - PHP >= 5.3.7
|
||||
* - the mcrypt extensions is loaded
|
||||
* - One of these two conditions is true:
|
||||
* - We're on Windows (DIRECTORY_SEPARATOR !== '/')
|
||||
* - We're not on Windows and /dev/urandom is readabale
|
||||
* (i.e. we're not in a chroot jail)
|
||||
* - Special case:
|
||||
* - If we're not on Windows, but the PHP version is between
|
||||
* 5.6.10 and 5.6.12, we don't want to use mcrypt. It will
|
||||
* hang indefinitely. This is bad.
|
||||
*/
|
||||
if (
|
||||
!is_callable('random_bytes')
|
||||
|
@ -130,8 +146,6 @@ if (PHP_VERSION_ID < 70000) {
|
|||
PHP_VERSION_ID >= 50307
|
||||
&&
|
||||
extension_loaded('mcrypt')
|
||||
&&
|
||||
(DIRECTORY_SEPARATOR !== '/' || $RandomCompatUrandom)
|
||||
) {
|
||||
// Prevent this code from hanging indefinitely on non-Windows;
|
||||
// see https://bugs.php.net/bug.php?id=69833
|
||||
|
@ -145,6 +159,10 @@ if (PHP_VERSION_ID < 70000) {
|
|||
}
|
||||
$RandomCompatUrandom = null;
|
||||
|
||||
/**
|
||||
* This is a Windows-specific fallback, for when the mcrypt extension
|
||||
* isn't loaded.
|
||||
*/
|
||||
if (
|
||||
!is_callable('random_bytes')
|
||||
&&
|
||||
|
|
Loading…
Reference in a new issue