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