mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-10-22 13:50:44 +02:00
address eslint errors
This commit is contained in:
parent
51481656ba
commit
f0560bcc27
8 changed files with 27 additions and 20 deletions
|
@ -90,8 +90,10 @@ jQuery.PrivateBin = (function($) {
|
|||
*/
|
||||
function CryptoData(data) {
|
||||
// store all keys in the default locations for drop-in replacement
|
||||
for (let key in data) {
|
||||
this[key] = data[key];
|
||||
for (const key in data) {
|
||||
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
||||
this[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3607,7 +3609,7 @@ jQuery.PrivateBin = (function($) {
|
|||
|
||||
// set date
|
||||
const created = comment.getCreated();
|
||||
const commentDate = created == 0 ? '' : ' (' + (new Date(created * 1000).toLocaleString()) + ')';
|
||||
const commentDate = created === 0 ? '' : ' (' + (new Date(created * 1000).toLocaleString()) + ')';
|
||||
$commentEntry.find('span.commentdate')
|
||||
.text(commentDate)
|
||||
.attr('title', 'CommentID: ' + comment.id);
|
||||
|
@ -5570,7 +5572,7 @@ jQuery.PrivateBin = (function($) {
|
|||
|
||||
if (window.getSelection) {
|
||||
text = window.getSelection().toString();
|
||||
} else if (document.selection && document.selection.type != 'Control') {
|
||||
} else if (document.selection && document.selection.type !== 'Control') {
|
||||
text = document.selection.createRange().text;
|
||||
}
|
||||
|
||||
|
@ -5727,7 +5729,7 @@ jQuery.PrivateBin = (function($) {
|
|||
|
||||
Alert.hideLoading();
|
||||
// only push new state if we are coming from a different one
|
||||
if (Helper.baseUri() != window.location) {
|
||||
if (Helper.baseUri() !== window.location) {
|
||||
history.pushState({type: 'create'}, document.title, Helper.baseUri());
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('Helper', function () {
|
|||
'ignores non-URL content',
|
||||
'string',
|
||||
function (content) {
|
||||
content = content.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, '');
|
||||
content = content.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', '');
|
||||
let clean = jsdom();
|
||||
$('body').html('<div id="foo"></div>');
|
||||
let e = $('#foo');
|
||||
|
@ -100,8 +100,8 @@ describe('Helper', function () {
|
|||
jsc.array(common.jscHashString()),
|
||||
'string',
|
||||
function (prefix, url, fragment, postfix) {
|
||||
prefix = prefix.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, '');
|
||||
postfix = ' ' + postfix.replace(/\r/g, '\n').replace(/\u0000/g, '');
|
||||
prefix = prefix.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', '');;
|
||||
postfix = ' ' + postfix.replace('\r', '\n').replace('\u0000', '');
|
||||
url.fragment = fragment.join('');
|
||||
let urlString = common.urlToString(url),
|
||||
clean = jsdom();
|
||||
|
@ -132,9 +132,9 @@ describe('Helper', function () {
|
|||
jsc.array(common.jscQueryString()),
|
||||
'string',
|
||||
function (prefix, query, postfix) {
|
||||
prefix = prefix.replace(/\r|\f/g, '\n').replace(/\u0000/g, '').replace(/\u000b/g, '');
|
||||
postfix = ' ' + postfix.replace(/\r/g, '\n').replace(/\u0000/g, '');
|
||||
let url = 'magnet:?' + query.join('').replace(/^&+|&+$/gm,''),
|
||||
prefix = prefix.replace(/\r|\f/g, '\n').replace('\u0000', '').replace('\u000b', '');
|
||||
postfix = ' ' + postfix.replace('\r', '\n').replace('\u0000', '');
|
||||
let url = 'magnet:?' + query.join('').replace(/^&+|&+$/gm, ''),
|
||||
clean = jsdom();
|
||||
$('body').html('<div id="foo"></div>');
|
||||
let e = $('#foo');
|
||||
|
@ -346,4 +346,3 @@ describe('Helper', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -192,7 +192,9 @@ describe('I18n', function () {
|
|||
|
||||
// mock
|
||||
clean = jsdom('', {cookie: ['lang=' + language]});
|
||||
// eslint-disable-line global-require
|
||||
$.PrivateBin.I18n.reset(language, require('../../i18n/' + language + '.json'));
|
||||
// eslint-enable-line global-require
|
||||
var loadedLang = $.PrivateBin.I18n.getLanguage(),
|
||||
result = $.PrivateBin.I18n.translate('Never'),
|
||||
alias = $.PrivateBin.I18n._('Never');
|
||||
|
|
|
@ -50,7 +50,7 @@ describe('PasteStatus', function () {
|
|||
'nestring',
|
||||
common.jscUrl(),
|
||||
function (schema, domain, url) {
|
||||
domain = domain.replace(/\P{Letter}|[\u00AA-\u00BA]/gu, '').toLowerCase();
|
||||
domain = domain.replace(/\P{Letter}|[\u{00AA}-\u{00BA}]/gu, '').toLowerCase();
|
||||
if (domain.length === 0) {
|
||||
domain = 'a';
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ describe('PasteViewer', function () {
|
|||
'\'">><marquee><img src=x onerror=confirm(1)></marquee>">' +
|
||||
'</plaintext\\></|\\><plaintext/onmouseover=prompt(1)>' +
|
||||
'<script>prompt(1)</script>@gmail.com<isindex formaction=' +
|
||||
'javascript:alert(/XSS/) type=submit>\'-->"></script>' +
|
||||
// obfuscate script URL from eslint rule: no-script-url
|
||||
'java' + 'script' + ':alert(/XSS/) type=submit>\'-->"></script>' +
|
||||
'<script>alert(document.cookie)</script>"><img/id="confirm' +
|
||||
'(1)"/alt="/"src="/"onerror=eval(id)>\'">',
|
||||
'<IMG SRC="javascript:alert(\'XSS\');">',
|
||||
|
@ -115,4 +116,3 @@ describe('PasteViewer', function () {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ describe('Prompt', function () {
|
|||
);
|
||||
$.PrivateBin.Model.reset();
|
||||
$.PrivateBin.Model.init();
|
||||
// eslint-disable-line global-require
|
||||
global.bootstrap = require('../bootstrap-5.3.7');
|
||||
// eslint-enable-line global-require
|
||||
$.PrivateBin.Prompt.init();
|
||||
$.PrivateBin.Prompt.requestPassword();
|
||||
$('#passworddecrypt').val(password);
|
||||
|
|
|
@ -323,12 +323,12 @@ describe('TopNav', function () {
|
|||
$.PrivateBin.TopNav.init();
|
||||
results.push(
|
||||
$('.navbar-toggle').hasClass('collapsed') &&
|
||||
$('#navbar').attr('aria-expanded') != 'true'
|
||||
$('#navbar').attr('aria-expanded') !== 'true'
|
||||
);
|
||||
$.PrivateBin.TopNav.collapseBar();
|
||||
results.push(
|
||||
$('.navbar-toggle').hasClass('collapsed') &&
|
||||
$('#navbar').attr('aria-expanded') != 'true'
|
||||
$('#navbar').attr('aria-expanded') !== 'true'
|
||||
);
|
||||
/*
|
||||
with the upgrade for bootstrap-3.3.7.js to bootstrap-3.4.1.js
|
||||
|
@ -517,10 +517,12 @@ describe('TopNav', function () {
|
|||
cleanup();
|
||||
});
|
||||
|
||||
// eslint-disable-line global-require
|
||||
var File = window.File,
|
||||
FileList = window.FileList,
|
||||
path = require('path'),
|
||||
mime = require('mime-types');
|
||||
// eslint-enable-line global-require
|
||||
|
||||
// mocking file input as per https://github.com/jsdom/jsdom/issues/1272
|
||||
function createFile(file_path) {
|
||||
|
@ -546,7 +548,7 @@ describe('TopNav', function () {
|
|||
}
|
||||
|
||||
const file_list = file_paths.map(fp => createFile(fp));
|
||||
file_list.__proto__ = Object.create(FileList.prototype);
|
||||
Object.setPrototypeOf(file_list, Object.create(FileList.prototype));
|
||||
|
||||
Object.defineProperty(input, 'files', {
|
||||
value: file_list,
|
||||
|
|
|
@ -59,7 +59,7 @@ function stubWinOpen($element) {
|
|||
openedUrl = url;
|
||||
return {};
|
||||
};
|
||||
} catch {
|
||||
} catch (e) {
|
||||
Object.defineProperty(win, 'open', {
|
||||
value: function (url) {
|
||||
openedUrl = url;
|
||||
|
@ -72,7 +72,7 @@ function stubWinOpen($element) {
|
|||
|
||||
return {
|
||||
getUrl: () => openedUrl,
|
||||
restore: () => { try { win.open = origOpen; } catch {} },
|
||||
restore: () => { try { win.open = origOpen; } catch (e) {} },
|
||||
win
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue