in light of the perf/size test results of Jdenticons, switch back to Identicons as the default

This commit is contained in:
El RIDO 2022-10-30 09:05:29 +01:00
parent 1892264cf0
commit 89d575ace3
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
5 changed files with 10 additions and 17 deletions

View file

@ -3,7 +3,7 @@
* **1.4.1 (not yet released)** * **1.4.1 (not yet released)**
* ADDED: Translations for Turkish, Slovak and Greek * ADDED: Translations for Turkish, Slovak and Greek
* ADDED: S3 Storage backend (#994) * ADDED: S3 Storage backend (#994)
* CHANGED: Switched to Jdenticons as the default for comment icons (#793) * ADDED: Jdenticons as an option for comment icons (#793)
* CHANGED: Avoid `SUPER` privilege for setting the `sql_mode` for MariaDB/MySQL (#919) * CHANGED: Avoid `SUPER` privilege for setting the `sql_mode` for MariaDB/MySQL (#919)
* CHANGED: Upgrading libraries to: zlib 1.2.13 * CHANGED: Upgrading libraries to: zlib 1.2.13
* FIXED: Revert to CREATE INDEX without IF NOT EXISTS clauses, to support MySQL (#943) * FIXED: Revert to CREATE INDEX without IF NOT EXISTS clauses, to support MySQL (#943)

View file

@ -69,7 +69,7 @@ languageselection = false
; used to get the IP of a comment poster if the server salt is leaked and a ; used to get the IP of a comment poster if the server salt is leaked and a
; SHA512 HMAC rainbow table is generated for all (relevant) IPs. ; SHA512 HMAC rainbow table is generated for all (relevant) IPs.
; Can be set to one these values: ; Can be set to one these values:
; "none" / "vizhash" / "identicon" / "jdenticon" (default). ; "none" / "identicon" (default) / "jdenticon" / "vizhash".
; icon = "none" ; icon = "none"
; Content Security Policy headers allow a website to restrict what sources are ; Content Security Policy headers allow a website to restrict what sources are

View file

@ -53,7 +53,7 @@ class Configuration
'languagedefault' => '', 'languagedefault' => '',
'urlshortener' => '', 'urlshortener' => '',
'qrcode' => true, 'qrcode' => true,
'icon' => 'jdenticon', 'icon' => 'identicon',
'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\'; style-src \'self\'; font-src \'self\'; frame-ancestors \'none\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads', 'cspheader' => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\'; style-src \'self\'; font-src \'self\'; frame-ancestors \'none\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads',
'zerobincompatibility' => false, 'zerobincompatibility' => false,
'httpwarning' => true, 'httpwarning' => true,

View file

@ -165,7 +165,10 @@ class Comment extends AbstractModel
if ($icon != 'none') { if ($icon != 'none') {
$pngdata = ''; $pngdata = '';
$hmac = TrafficLimiter::getHash(); $hmac = TrafficLimiter::getHash();
if ($icon == 'jdenticon') { if ($icon == 'identicon') {
$identicon = new Identicon();
$pngdata = $identicon->getImageDataUri($hmac, 16);
} elseif ($icon == 'jdenticon') {
$jdenticon = new Jdenticon(array( $jdenticon = new Jdenticon(array(
'hash' => $hmac, 'hash' => $hmac,
'size' => 16, 'size' => 16,
@ -175,9 +178,6 @@ class Comment extends AbstractModel
), ),
)); ));
$pngdata = $jdenticon->getImageDataUri('png'); $pngdata = $jdenticon->getImageDataUri('png');
} elseif ($icon == 'identicon') {
$identicon = new Identicon();
$pngdata = $identicon->getImageDataUri($hmac, 16);
} elseif ($icon == 'vizhash') { } elseif ($icon == 'vizhash') {
$vh = new Vizhash16x16(); $vh = new Vizhash16x16();
$pngdata = 'data:image/png;base64,' . base64_encode( $pngdata = 'data:image/png;base64,' . base64_encode(

View file

@ -1,6 +1,6 @@
<?php <?php
use Jdenticon\Identicon; use Identicon\Identicon;
use PrivateBin\Configuration; use PrivateBin\Configuration;
use PrivateBin\Data\Database; use PrivateBin\Data\Database;
use PrivateBin\Model; use PrivateBin\Model;
@ -314,15 +314,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
$comment->get(); $comment->get();
$comment->store(); $comment->store();
$identicon = new Identicon(array( $identicon = new Identicon();
'hash' => TrafficLimiter::getHash(), $pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
'size' => 16,
'style' => array(
'backgroundColor' => '#fff0', // fully transparent, for dark mode
'padding' => 0,
),
));
$pngdata = $identicon->getImageDataUri('png');
$comment = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']); $comment = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']);
$this->assertEquals($pngdata, $comment['meta']['icon'], 'icon gets set'); $this->assertEquals($pngdata, $comment['meta']['icon'], 'icon gets set');
} }