This commit is contained in:
CommanderRoot 2024-04-09 22:35:36 -07:00 committed by GitHub
commit 021ab8241d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 35 additions and 38 deletions

View File

@ -20,11 +20,11 @@ function checkIfPasswordIsExposedOnline(password) {
.then((sha1) => { .then((sha1) => {
kdbxweb.ByteUtils.zeroBuffer(passwordBytes); kdbxweb.ByteUtils.zeroBuffer(passwordBytes);
sha1 = kdbxweb.ByteUtils.bytesToHex(sha1).toUpperCase(); sha1 = kdbxweb.ByteUtils.bytesToHex(sha1).toUpperCase();
const shaFirst = sha1.substr(0, 5); const shaFirst = sha1.slice(0, 5);
return fetch(`https://api.pwnedpasswords.com/range/${shaFirst}`) return fetch(`https://api.pwnedpasswords.com/range/${shaFirst}`)
.then((response) => response.text()) .then((response) => response.text())
.then((response) => { .then((response) => {
const isPresent = response.includes(sha1.substr(5)); const isPresent = response.includes(sha1.slice(5));
exposedPasswords[saltedValue] = isPresent; exposedPasswords[saltedValue] = isPresent;
return isPresent; return isPresent;
}); });

View File

@ -114,8 +114,8 @@ class View extends EventEmitter {
const spaceIx = eventDef.indexOf(' '); const spaceIx = eventDef.indexOf(' ');
let event, selector; let event, selector;
if (spaceIx > 0) { if (spaceIx > 0) {
event = eventDef.substr(0, spaceIx); event = eventDef.slice(0, spaceIx);
selector = eventDef.substr(spaceIx + 1); selector = eventDef.slice(spaceIx + 1);
if (DoesNotBubble[event]) { if (DoesNotBubble[event]) {
this.elementEventListeners.push({ event, selector, method, els: [] }); this.elementEventListeners.push({ event, selector, method, els: [] });
continue; continue;

View File

@ -15,7 +15,7 @@ Handlebars.registerHelper('res', function (key, options) {
Handlebars.registerHelper('Res', (key, options) => { Handlebars.registerHelper('Res', (key, options) => {
let value = Locale[key]; let value = Locale[key];
if (value) { if (value) {
value = value[0].toUpperCase() + value.substr(1); value = value[0].toUpperCase() + value.slice(1);
const ix = value.indexOf('{}'); const ix = value.indexOf('{}');
if (ix >= 0) { if (ix >= 0) {
value = value.replace('{}', options.fn(this)); value = value.replace('{}', options.fn(this));

View File

@ -273,7 +273,7 @@ class EntryModel extends Model {
_getReferenceValue(fieldRefId, idStr) { _getReferenceValue(fieldRefId, idStr) {
const id = new Uint8Array(16); const id = new Uint8Array(16);
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
id[i] = parseInt(idStr.substr(i * 2, 2), 16); id[i] = parseInt(idStr.slice(i * 2, i * 2 + 2), 16);
} }
const uuid = new kdbxweb.KdbxUuid(id); const uuid = new kdbxweb.KdbxUuid(id);
const entry = this.file.getEntry(this.file.subId(uuid.id)); const entry = this.file.getEntry(this.file.subId(uuid.id));

View File

@ -32,7 +32,7 @@ const ThemeVars = {
// definitions are written like this: // definitions are written like this:
// map-merge((def:val, def:val, ..., last-def:val),$t) // map-merge((def:val, def:val, ..., last-def:val),$t)
// so, the last item has "),$" captured, here we're removing that bracket // so, the last item has "),$" captured, here we're removing that bracket
def = def.substr(0, def.length - 1); def = def.slice(0, -1);
} }
const propName = '--' + name; const propName = '--' + name;
const currentValue = cssStyle.getPropertyValue(propName); const currentValue = cssStyle.getPropertyValue(propName);
@ -78,7 +78,7 @@ const ThemeVars = {
} }
} }
if (/^L/.test(arg)) { if (/^L/.test(arg)) {
return locals[arg.substr(1)]; return locals[arg.slice(1)];
} }
if (/%$/.test(arg)) { if (/%$/.test(arg)) {
return arg.replace(/%$/, '') / 100; return arg.replace(/%$/, '') / 100;

View File

@ -30,9 +30,9 @@ class StorageDropbox extends StorageBase {
if (rootFolder) { if (rootFolder) {
const ix = path.toLowerCase().indexOf(rootFolder.toLowerCase()); const ix = path.toLowerCase().indexOf(rootFolder.toLowerCase());
if (ix === 0) { if (ix === 0) {
path = path.substr(rootFolder.length); path = path.slice(rootFolder.length);
} else if (ix === 1) { } else if (ix === 1) {
path = path.substr(rootFolder.length + 1); path = path.slice(rootFolder.length + 1);
} }
path = UrlFormat.fixSlashes('/' + path); path = UrlFormat.fixSlashes('/' + path);
} }
@ -42,7 +42,7 @@ class StorageDropbox extends StorageBase {
_fixConfigFolder(folder) { _fixConfigFolder(folder) {
folder = folder.replace(/\\/g, '/').trim(); folder = folder.replace(/\\/g, '/').trim();
if (folder[0] === '/') { if (folder[0] === '/') {
folder = folder.substr(1); folder = folder.slice(1);
} }
return folder; return folder;
} }

View File

@ -397,7 +397,7 @@ class StorageWebDav extends StorageBase {
return null; return null;
} }
return kdbxweb.CryptoEngine.sha256(xhr.response).then((hash) => { return kdbxweb.CryptoEngine.sha256(xhr.response).then((hash) => {
const rev = kdbxweb.ByteUtils.bytesToHex(hash).substr(0, 10); const rev = kdbxweb.ByteUtils.bytesToHex(hash).slice(0, 10);
this.logger.debug('Calculated rev by content', `${xhr.response.byteLength} bytes`, rev); this.logger.debug('Calculated rev by content', `${xhr.response.byteLength} bytes`, rev);
return { rev }; return { rev };
}); });

View File

@ -15,9 +15,9 @@ const Color = function (arg) {
if (hexMatch) { if (hexMatch) {
const digits = hexMatch[1]; const digits = hexMatch[1];
const len = digits.length === 3 ? 1 : 2; const len = digits.length === 3 ? 1 : 2;
this.r = parseInt(digits.substr(0, len), 16); this.r = parseInt(digits.slice(0, len), 16);
this.g = parseInt(digits.substr(len, len), 16); this.g = parseInt(digits.slice(len, len * 2), 16);
this.b = parseInt(digits.substr(len * 2, len), 16); this.b = parseInt(digits.slice(len * 2, len * 3), 16);
this.a = 1; this.a = 1;
this.setHsl(); this.setHsl();
} else if (arg instanceof Color) { } else if (arg instanceof Color) {

View File

@ -44,7 +44,7 @@ class CsvParser {
nextIndex = this.csv.length; nextIndex = this.csv.length;
} }
const value = this.csv.substr(this.index, nextIndex - this.index); const value = this.csv.slice(this.index, nextIndex);
this.line.push(value); this.line.push(value);
this.index = nextIndex; this.index = nextIndex;
@ -66,23 +66,23 @@ class CsvParser {
const charAfterBackslash = this.csv[nextBackslashIndex + 1]; const charAfterBackslash = this.csv[nextBackslashIndex + 1];
if (charAfterBackslash === '"' || charAfterBackslash === '\\') { if (charAfterBackslash === '"' || charAfterBackslash === '\\') {
this.value += this.value +=
this.csv.substr(this.index, nextBackslashIndex - this.index) + this.csv.slice(this.index, nextBackslashIndex) +
charAfterBackslash; charAfterBackslash;
this.index = nextBackslashIndex + 2; this.index = nextBackslashIndex + 2;
} else { } else {
this.value += this.csv.substr(this.index, nextBackslashIndex - this.index + 1); this.value += this.csv.slice(this.index, nextBackslashIndex + 1);
this.index = nextBackslashIndex + 1; this.index = nextBackslashIndex + 1;
} }
return this.handleQuotedValue; return this.handleQuotedValue;
} }
if (this.csv[nextQuoteIndex + 1] === '"') { if (this.csv[nextQuoteIndex + 1] === '"') {
this.value += this.csv.substr(this.index, nextQuoteIndex - this.index + 1); this.value += this.csv.slice(this.index, nextQuoteIndex + 1);
this.index = nextQuoteIndex + 2; this.index = nextQuoteIndex + 2;
return this.handleQuotedValue; return this.handleQuotedValue;
} }
this.value += this.csv.substr(this.index, nextQuoteIndex - this.index); this.value += this.csv.slice(this.index, nextQuoteIndex);
this.index = nextQuoteIndex + 1; this.index = nextQuoteIndex + 1;
this.line.push(this.value); this.line.push(this.value);
this.value = ''; this.value = '';

View File

@ -93,7 +93,7 @@ Otp.prototype.hmac = function (data, callback) {
Otp.hmacToDigits = function (hmac, length) { Otp.hmacToDigits = function (hmac, length) {
let code = hmac.toString(); let code = hmac.toString();
code = Otp.leftPad(code.substr(code.length - length), length); code = Otp.leftPad(code.slice(-length), length);
return code; return code;
}; };
@ -121,7 +121,7 @@ Otp.fromBase32 = function (str) {
} }
const hex = new Uint8Array(Math.floor(bin.length / 8)); const hex = new Uint8Array(Math.floor(bin.length / 8));
for (i = 0; i < hex.length; i++) { for (i = 0; i < hex.length; i++) {
const chunk = bin.substr(i * 8, 8); const chunk = bin.slice(i * 8, i * 8 + 8);
hex[i] = parseInt(chunk, 2); hex[i] = parseInt(chunk, 2);
} }
return hex.buffer; return hex.buffer;

View File

@ -5,7 +5,7 @@ const StringFormat = {
if (!str) { if (!str) {
return ''; return '';
} }
return str[0].toUpperCase() + str.substr(1); return str[0].toUpperCase() + str.slice(1);
}, },
pad(num, digits) { pad(num, digits) {

View File

@ -7,7 +7,7 @@ const UrlFormat = {
getDataFileName(url) { getDataFileName(url) {
const ix = url.lastIndexOf('/'); const ix = url.lastIndexOf('/');
if (ix >= 0) { if (ix >= 0) {
url = url.substr(ix + 1); url = url.slice(ix + 1);
} }
url = url.replace(/\?.*/, '').replace(/\.kdbx/i, ''); url = url.replace(/\?.*/, '').replace(/\.kdbx/i, '');
return url; return url;

View File

@ -100,7 +100,7 @@ const PasswordGenerator = {
} }
result += ch; result += ch;
} }
return result.substr(0, opts.length); return result.slice(0, opts.length);
}, },
deriveOpts(password) { deriveOpts(password) {

View File

@ -316,7 +316,7 @@ function generate(options) {
while (wordObj.word.length < safeMaxLength) { while (wordObj.word.length < safeMaxLength) {
addSyllable(wordObj); addSyllable(wordObj);
} }
return postProcess(wordObj).substr(0, length); return postProcess(wordObj).slice(0, length);
} }
const phonetic = { generate }; const phonetic = { generate };

View File

@ -75,7 +75,7 @@ class AutoTypeHintView extends View {
insertText(text) { insertText(text) {
const pos = this.input.selectionEnd || this.input.value.length; const pos = this.input.selectionEnd || this.input.value.length;
this.input.value = this.input.value.substr(0, pos) + text + this.input.value.substr(pos); this.input.value = this.input.value.slice(0, pos) + text + this.input.value.slice(pos);
this.input.selectionStart = this.input.selectionEnd = pos + text.length; this.input.selectionStart = this.input.selectionEnd = pos + text.length;
this.input.dispatchEvent(new Event('input', { bubbles: true })); this.input.dispatchEvent(new Event('input', { bubbles: true }));
} }

View File

@ -335,7 +335,7 @@ class DetailsView extends View {
break; break;
default: default:
if (e.item.lastIndexOf('add:', 0) === 0) { if (e.item.lastIndexOf('add:', 0) === 0) {
const fieldName = e.item.substr(4); const fieldName = e.item.slice(4);
const fieldView = this.fieldViews.find((f) => f.model.name === fieldName); const fieldView = this.fieldViews.find((f) => f.model.name === fieldName);
fieldView.show(); fieldView.show();
fieldView.edit(); fieldView.edit();
@ -571,7 +571,7 @@ class DetailsView extends View {
fieldChanged(e) { fieldChanged(e) {
if (e.field) { if (e.field) {
if (e.field[0] === '$') { if (e.field[0] === '$') {
let fieldName = e.field.substr(1); let fieldName = e.field.slice(1);
if (fieldName === 'otp') { if (fieldName === 'otp') {
if (this.otpFieldChanged(e.val)) { if (this.otpFieldChanged(e.val)) {
this.entryUpdated(); this.entryUpdated();

View File

@ -94,7 +94,7 @@ class FieldViewTags extends FieldViewText {
const last = tags[tags.length - 1]; const last = tags[tags.length - 1];
const isLastPart = last && this.model.tags.indexOf(last) < 0; const isLastPart = last && this.model.tags.indexOf(last) < 0;
if (isLastPart) { if (isLastPart) {
newVal = newVal.substr(0, newVal.lastIndexOf(last)) + selectedTag; newVal = newVal.substring(0, newVal.lastIndexOf(last)) + selectedTag;
} else { } else {
newVal += ', ' + selectedTag; newVal += ', ' + selectedTag;
} }

View File

@ -228,10 +228,7 @@ class SelectEntryView extends View {
backSpacePressed() { backSpacePressed() {
if (this.model.filter.text) { if (this.model.filter.text) {
this.model.filter.text = this.model.filter.text.substr( this.model.filter.text = this.model.filter.text.slice(0, -1);
0,
this.model.filter.text.length - 1
);
this.render(); this.render();
} }
} }

View File

@ -18,7 +18,7 @@ for (const svgDir of svgDirs) {
.filter((icon) => icon.endsWith('.svg')) .filter((icon) => icon.endsWith('.svg'))
.forEach((icon) => { .forEach((icon) => {
const svgIconPath = path.join(svgDir, icon); const svgIconPath = path.join(svgDir, icon);
const iconName = icon.substr(0, icon.length - 4) + suffix; const iconName = icon.slice(0, -4) + suffix;
allIcons[iconName] = svgIconPath; allIcons[iconName] = svgIconPath;
}); });
} }

View File

@ -29,7 +29,7 @@ module.exports = function (grunt) {
if (stat && stat.isDirectory()) { if (stat && stat.isDirectory()) {
await walk(file); await walk(file);
} else { } else {
const relFile = file.substr(appPath.length + 1); const relFile = file.slice(appPath.length + 1);
const fileData = grunt.file.read(file, { encoding: null }); const fileData = grunt.file.read(file, { encoding: null });
signatures[relFile] = await getSignature(fileData); signatures[relFile] = await getSignature(fileData);
signedFiles.push(relFile); signedFiles.push(relFile);

View File

@ -329,7 +329,7 @@ async function processFirstMessageFromSocket(socket, message) {
appName = parentProcessInfo appName = parentProcessInfo
? AppNames[parentProcessInfo.appName] ?? parentProcessInfo.appName ? AppNames[parentProcessInfo.appName] ?? parentProcessInfo.appName
: 'Unidentified browser'; : 'Unidentified browser';
appName = appName[0].toUpperCase() + appName.substr(1); appName = appName[0].toUpperCase() + appName.slice(1);
} }
state.active = true; state.active = true;

View File

@ -135,7 +135,7 @@ function checkFilePath(path, ext) {
if (!path) { if (!path) {
throw 'File not specified: ' + ext; throw 'File not specified: ' + ext;
} }
if (path.substr(-(ext.length + 1)) !== '.' + ext) { if (path.slice(-(ext.length + 1)) !== '.' + ext) {
throw 'Bad file extension: ' + ext + ' (' + path + ')'; throw 'Bad file extension: ' + ext + ' (' + path + ')';
} }
var file = Application('System Events').files.byName(path); var file = Application('System Events').files.byName(path);