From a4eaa77b82ee80eb79a0d494ed93e1561ad3dbc2 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 25 Jan 2026 09:41:52 +0100 Subject: [PATCH] address semicolon insertion lint > Code that uses automatic semicolon insertion inconsistently is hard to read and maintain. See: https://github.com/PrivateBin/PrivateBin/security/quality/rules/js%2Fautomatic-semicolon-insertion --- js/common.js | 6 +++--- js/privatebin.js | 12 +++++++----- js/test/AttachmentViewer.js | 4 ++-- js/{zlib-1.3.1-1.js => zlib-1.3.1-2.js} | 2 +- lib/Configuration.php | 4 ++-- tpl/bootstrap.php | 2 +- tpl/bootstrap5.php | 2 +- 7 files changed, 17 insertions(+), 15 deletions(-) rename js/{zlib-1.3.1-1.js => zlib-1.3.1-2.js} (99%) diff --git a/js/common.js b/js/common.js index fb3129ca..50da192c 100644 --- a/js/common.js +++ b/js/common.js @@ -10,7 +10,7 @@ global.WebCrypto = require('@peculiar/webcrypto').Crypto; // application libraries to test global.$ = global.jQuery = require('./jquery-3.7.1'); -global.zlib = require('./zlib-1.3.1-1').zlib; +global.zlib = require('./zlib-1.3.1-2').zlib; require('./prettify'); global.prettyPrint = window.PR.prettyPrint; global.prettyPrintOne = window.PR.prettyPrintOne; @@ -82,10 +82,10 @@ function parseMime(line) { // these to be character encoding agnostic exports.atob = function(encoded) { return Buffer.from(encoded, 'base64').toString('binary'); -} +}; exports.btoa = function(text) { return Buffer.from(text, 'binary').toString('base64'); -} +}; // provides random lowercase characters from a to z exports.jscA2zString = function() { diff --git a/js/privatebin.js b/js/privatebin.js index a6cdfd6e..54f72d50 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -555,13 +555,14 @@ jQuery.PrivateBin = (function($) { * @param {string} str * @return {string} escaped HTML */ - me.htmlEntities = function(str) { + me.htmlEntities = function(str) + { return String(str).replace( /[&<>"'`=\/]/g, function(s) { return entityMap[s]; } ); - } + }; /** * calculate expiration date given initial date and expiration period @@ -572,7 +573,8 @@ jQuery.PrivateBin = (function($) { * @param {string|number} expirationDisplayStringOrSecondsToExpire - may not be empty * @return {Date} */ - me.calculateExpirationDate = function(initialDate, expirationDisplayStringOrSecondsToExpire) { + me.calculateExpirationDate = function(initialDate, expirationDisplayStringOrSecondsToExpire) + { let expirationDate = new Date(initialDate), secondsToExpiration = expirationDisplayStringOrSecondsToExpire; if (typeof expirationDisplayStringOrSecondsToExpire === 'string') { @@ -617,7 +619,7 @@ jQuery.PrivateBin = (function($) { } return result; - } + }; /** * resets state, used for unit testing @@ -1312,7 +1314,7 @@ jQuery.PrivateBin = (function($) { spec[1] = atob(spec[1]); if (spec[7] === 'zlib') { if (typeof zlib === 'undefined') { - throw 'Error decompressing document, your browser does not support WebAssembly. Please use another browser to view this document.' + throw 'Error decompressing document, your browser does not support WebAssembly. Please use another browser to view this document.'; } } try { diff --git a/js/test/AttachmentViewer.js b/js/test/AttachmentViewer.js index 04f9636e..a9ab0f6c 100644 --- a/js/test/AttachmentViewer.js +++ b/js/test/AttachmentViewer.js @@ -49,7 +49,7 @@ describe('AttachmentViewer', function () { {value: function(blob) { return 'blob:' + location.origin + '/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'; }} - ) + ); } $.PrivateBin.AttachmentViewer.init(); $.PrivateBin.Model.init(); @@ -152,7 +152,7 @@ describe('AttachmentViewer', function () { {value: function(blob) { return 'blob:' + location.origin + '/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'; }} - ) + ); } $.PrivateBin.AttachmentViewer.init(); $.PrivateBin.Model.init(); diff --git a/js/zlib-1.3.1-1.js b/js/zlib-1.3.1-2.js similarity index 99% rename from js/zlib-1.3.1-1.js rename to js/zlib-1.3.1-2.js index 5d942dca..3e38c3ea 100644 --- a/js/zlib-1.3.1-1.js +++ b/js/zlib-1.3.1-2.js @@ -129,7 +129,7 @@ rawDef.destroy(); return ret; }, - } + }; return ret; } diff --git a/lib/Configuration.php b/lib/Configuration.php index 66d98419..1ac896f9 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -122,10 +122,10 @@ class Configuration 'js/kjua-0.10.0.js' => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==', 'js/legacy.js' => 'sha512-rGXYUpIqbFoHAgBXZ0UlJBdNAIMOC9EQ67MG0X46D5uRB8LvwzgKirbSQRGdYfk8I2jsUcm+tvHXYboUnC6DUg==', 'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==', - 'js/privatebin.js' => 'sha512-a8zeCawerrfYBa3x0fiaqZMtR1k9Fd0ZKMl2rhR2M7q25dGHDaoZOzn5xk9AiNHR+Enn7srauqOxnnI1XlooCw==', + 'js/privatebin.js' => 'sha512-Ln6NW/gCPGV/Ol6EEJUIqGOm5yklpbZ9/C3iexn+ab4bLY62Ke26ZgAz6YuYUH5aHhLhTZkodQQpOK+jdZg2jg==', 'js/purify-3.3.0.js' => 'sha512-lsHD5zxs4lu/NDzaaibe27Vd2t7Cy9JQ3qDHUvDfb4oZvKoWDNEhwUY+4bT3R68cGgpgCYp8U1x2ifeVxqurdQ==', 'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==', - 'js/zlib-1.3.1-1.js' => 'sha512-5bU9IIP4PgBrOKLZvGWJD4kgfQrkTz8Z3Iqeu058mbQzW3mCumOU6M3UVbVZU9rrVoVwaW4cZK8U8h5xjF88eQ==', + 'js/zlib-1.3.1-2.js' => 'sha512-4gT+v+BkBqdVBbKOO4qKGOAzuay+v1FmOLksS+bMgQ08Oo4xEb3X48Xq1Kv2b4HtiCQA7xq9dFRzxal7jmQI7w==', ), ); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index eb759ae4..ab45060e 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -50,7 +50,7 @@ if ($QRCODE) : - _scriptTag('js/zlib-1.3.1-1.js', 'defer'); ?> + _scriptTag('js/zlib-1.3.1-2.js', 'defer'); ?> _scriptTag('js/base-x-5.0.1.js', 'defer'); ?> _scriptTag('js/bootstrap-3.4.1.js', 'defer'); ?> - _scriptTag('js/zlib-1.3.1-1.js', 'defer'); ?> + _scriptTag('js/zlib-1.3.1-2.js', 'defer'); ?> _scriptTag('js/base-x-5.0.1.js', 'defer'); ?> _scriptTag('js/bootstrap-5.3.8.js', 'defer'); ?> _scriptTag('js/dark-mode-switch.js', 'defer'); ?>