fsSize() fix drive sanitation (windows)

This commit is contained in:
Sebastian Hildebrandt 2025-12-16 07:18:20 +01:00
parent d3b03e973b
commit c52f9fd07f
6 changed files with 767 additions and 512 deletions

View File

@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.27.14 | 2025-12-15 | `fsSize()` fix drive sanitation (windows) |
| 5.27.13 | 2025-12-10 | `cpuCurrentSpeed()` fix hasOwnProperty |
| 5.27.12 | 2025-12-09 | `networkConnections()` fix pid issue (macOS) |
| 5.27.11 | 2025-10-05 | `system()` added latest mac studio versions (macOS) |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.27.14</th>
<td>2025-12-16</td>
<td><span class="code">fsSize()</span> fix sanitation drive (windows)</td>
</tr>
<tr>
<th scope="row">5.27.13</th>
<td>2025-12-10</td>

View File

@ -166,11 +166,11 @@
<body>
<header class="bg-image-full">
<div class="top-container">
<a href="security.html" class="recommendation">Security advisory:<br>Update to v5.23.7</a>
<a href="security.html" class="recommendation">Security advisory:<br>Update to v5.27.14</a>
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.27.13</span></div>
<div class="version">New Version: <span id="version">5.27.14</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -44,6 +44,21 @@
<div class="col-12 sectionheader">
<div class="title">Security Advisories</div>
<div class="text">
<h2>fsSize Command Injection Vulnerability</h2>
<p><span class="bold">Affected versions:</span>
&lt; 5.23.14<br>
<span class="bold">Date:</span> 2025-12-16<br>
<span class="bold">CVE indentifier</span> CVE-???
</p>
<h4>Impact</h4>
<p>We had an issue that there was a possibility to perform a potential command injection possibility by manipulating Win32_logicaldisk input in <span class="code">fsSize()</span> on windows machines.</p>
<h4>Patch</h4>
<p>Problem was fixed with parameter checking. If you are using version 5, please upgrade to version >= 5.27.14.</p>
<hr>
<br>
<h2>SSID Command Injection Vulnerability</h2>
<p><span class="bold">Affected versions:</span>
&lt; 5.23.7<br>

File diff suppressed because it is too large Load Diff

View File

@ -22,12 +22,12 @@ const execSync = require('child_process').execSync;
const util = require('util');
let _platform = process.platform;
const _linux = (_platform === 'linux' || _platform === 'android');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _netbsd = (_platform === 'netbsd');
const _linux = _platform === 'linux' || _platform === 'android';
const _darwin = _platform === 'darwin';
const _windows = _platform === 'win32';
const _freebsd = _platform === 'freebsd';
const _openbsd = _platform === 'openbsd';
const _netbsd = _platform === 'netbsd';
let _cores = 0;
let wmicPath = '';
@ -105,7 +105,9 @@ function unique(obj) {
let stringify = {};
for (let i = 0; i < obj.length; i++) {
let keys = Object.keys(obj[i]);
keys.sort(function (a, b) { return a - b; });
keys.sort(function (a, b) {
return a - b;
});
let str = '';
for (let j = 0; j < keys.length; j++) {
str += JSON.stringify(keys[j]);
@ -124,9 +126,10 @@ function sortByKey(array, keys) {
let x = '';
let y = '';
keys.forEach(function (key) {
x = x + a[key]; y = y + b[key];
x = x + a[key];
y = y + b[key];
});
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
return x < y ? -1 : x > y ? 1 : 0;
});
}
@ -148,7 +151,7 @@ function getValue(lines, property, separator, trimmed, lineMatch) {
if (trimmed) {
lineLower = lineLower.trim();
}
if (lineLower.startsWith(property) && (lineMatch ? (lineLower.match(property + separator)) || (lineLower.match(property + ' ' + separator)) : true)) {
if (lineLower.startsWith(property) && (lineMatch ? lineLower.match(property + separator) || lineLower.match(property + ' ' + separator) : true)) {
const parts = trimmed ? line.trim().split(separator) : line.split(separator);
if (parts.length >= 2) {
parts.shift();
@ -170,11 +173,15 @@ function decodeEscapeSequence(str, base) {
function detectSplit(str) {
let seperator = '';
let part = 0;
str.split('').forEach(element => {
str.split('').forEach((element) => {
if (element >= '0' && element <= '9') {
if (part === 1) { part++; }
if (part === 1) {
part++;
}
} else {
if (part === 0) { part++; }
if (part === 0) {
part++;
}
if (part === 1) {
seperator += element;
}
@ -194,7 +201,14 @@ function parseTime(t, pmDesignator) {
if (parts[2]) {
parts[1] += parts[2];
}
let isPM = (parts[1] && (parts[1].toLowerCase().indexOf('pm') > -1) || (parts[1].toLowerCase().indexOf('p.m.') > -1) || (parts[1].toLowerCase().indexOf('p. m.') > -1) || (parts[1].toLowerCase().indexOf('n') > -1) || (parts[1].toLowerCase().indexOf('ch') > -1) || (parts[1].toLowerCase().indexOf('ös') > -1) || (pmDesignator && parts[1].toLowerCase().indexOf(pmDesignator) > -1));
let isPM =
(parts[1] && parts[1].toLowerCase().indexOf('pm') > -1) ||
parts[1].toLowerCase().indexOf('p.m.') > -1 ||
parts[1].toLowerCase().indexOf('p. m.') > -1 ||
parts[1].toLowerCase().indexOf('n') > -1 ||
parts[1].toLowerCase().indexOf('ch') > -1 ||
parts[1].toLowerCase().indexOf('ös') > -1 ||
(pmDesignator && parts[1].toLowerCase().indexOf(pmDesignator) > -1);
hour = parseInt(parts[0], 10);
min = parseInt(parts[1], 10);
hour = isPM && hour < 12 ? hour + 12 : hour;
@ -209,7 +223,7 @@ function parseDateTime(dt, culture) {
};
culture = culture || {};
let dateFormat = (culture.dateFormat || '').toLowerCase();
let pmDesignator = (culture.pmDesignator || '');
let pmDesignator = culture.pmDesignator || '';
const parts = dt.split(' ');
if (parts[0]) {
@ -221,7 +235,7 @@ function parseDateTime(dt, culture) {
// Dateformat: yyyy/mm/dd
result.date = dtparts[0] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[2]).substr(-2);
} else if (dtparts[2].length === 2) {
if ((dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1)) {
if (dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1) {
// Dateformat: mm/dd/yy
result.date = '20' + dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
} else {
@ -230,7 +244,13 @@ function parseDateTime(dt, culture) {
}
} else {
// Dateformat: mm/dd/yyyy or dd/mm/yyyy
const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (dt.toLowerCase().indexOf('p.m.') > -1) || (dt.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (dt.toLowerCase().indexOf('a.m.') > -1) || (dt.toLowerCase().indexOf('a. m.') > -1));
const isEN =
dt.toLowerCase().indexOf('pm') > -1 ||
dt.toLowerCase().indexOf('p.m.') > -1 ||
dt.toLowerCase().indexOf('p. m.') > -1 ||
dt.toLowerCase().indexOf('am') > -1 ||
dt.toLowerCase().indexOf('a.m.') > -1 ||
dt.toLowerCase().indexOf('a. m.') > -1;
if ((isEN || dateFormat.indexOf('/d/') > -1 || dateFormat.indexOf('/dd/') > -1) && dateFormat.indexOf('dd/') !== 0) {
// Dateformat: mm/dd/yyyy
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
@ -270,7 +290,7 @@ function parseDateTime(dt, culture) {
}
function parseHead(head, rights) {
let space = (rights > 0);
let space = rights > 0;
let count = 1;
let from = 0;
let to = 0;
@ -366,7 +386,7 @@ function wmic(command) {
return new Promise((resolve) => {
process.nextTick(() => {
try {
powerShell(getWmic() + ' ' + command).then(stdout => {
powerShell(getWmic() + ' ' + command).then((stdout) => {
resolve(stdout, '');
});
} catch (e) {
@ -435,7 +455,9 @@ function powerShellStart() {
powerShellProceedResults(_psResult + _psError);
});
_psChild.on('close', function () {
if (_psChild) { _psChild.kill(); }
if (_psChild) {
_psChild.kill();
}
});
}
}
@ -449,13 +471,14 @@ function powerShellRelease() {
_psPersistent = false;
}
} catch (e) {
if (_psChild) { _psChild.kill(); }
if (_psChild) {
_psChild.kill();
}
}
_psChild = null;
}
function powerShell(cmd) {
/// const pattern = [
/// '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
/// '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
@ -483,7 +506,6 @@ function powerShell(cmd) {
}
});
});
} else {
let result = '';
@ -640,17 +662,7 @@ function smartMonToolsInstalled() {
// https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#hardware-revision-codes
function isRaspberry(cpuinfo) {
const PI_MODEL_NO = [
'BCM2708',
'BCM2709',
'BCM2710',
'BCM2711',
'BCM2712',
'BCM2835',
'BCM2836',
'BCM2837',
'BCM2837B0'
];
const PI_MODEL_NO = ['BCM2708', 'BCM2709', 'BCM2710', 'BCM2711', 'BCM2712', 'BCM2835', 'BCM2836', 'BCM2837', 'BCM2837B0'];
if (_rpi_cpuinfo !== null) {
cpuinfo = _rpi_cpuinfo;
} else if (cpuinfo === undefined) {
@ -664,7 +676,7 @@ function isRaspberry(cpuinfo) {
const hardware = getValue(cpuinfo, 'hardware');
const model = getValue(cpuinfo, 'model');
return ((hardware && PI_MODEL_NO.indexOf(hardware) > -1) || (model && model.indexOf('Raspberry Pi') > -1));
return (hardware && PI_MODEL_NO.indexOf(hardware) > -1) || (model && model.indexOf('Raspberry Pi') > -1);
}
function isRaspbian() {
@ -675,7 +687,7 @@ function isRaspbian() {
return false;
}
const id = getValue(osrelease, 'id', '=');
return (id && id.indexOf('raspbian') > -1);
return id && id.indexOf('raspbian') > -1;
}
function execWin(cmd, opts, callback) {
@ -693,7 +705,7 @@ function darwinXcodeExists() {
const cmdLineToolsExists = fs.existsSync('/Library/Developer/CommandLineTools/usr/bin/');
const xcodeAppExists = fs.existsSync('/Applications/Xcode.app/Contents/Developer/Tools');
const xcodeExists = fs.existsSync('/Library/Developer/Xcode/');
return (cmdLineToolsExists || xcodeExists || xcodeAppExists);
return cmdLineToolsExists || xcodeExists || xcodeAppExists;
}
function nanoSeconds() {
@ -707,7 +719,7 @@ function nanoSeconds() {
function countUniqueLines(lines, startingWith) {
startingWith = startingWith || '';
const uniqueLines = [];
lines.forEach(line => {
lines.forEach((line) => {
if (line.startsWith(startingWith)) {
if (uniqueLines.indexOf(line) === -1) {
uniqueLines.push(line);
@ -720,7 +732,7 @@ function countUniqueLines(lines, startingWith) {
function countLines(lines, startingWith) {
startingWith = startingWith || '';
const uniqueLines = [];
lines.forEach(line => {
lines.forEach((line) => {
if (line.startsWith(startingWith)) {
uniqueLines.push(line);
}
@ -729,40 +741,46 @@ function countLines(lines, startingWith) {
}
function sanitizeShellString(str, strict) {
if (typeof strict === 'undefined') { strict = false; }
if (typeof strict === 'undefined') {
strict = false;
}
const s = str || '';
let result = '';
const l = mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (!(s[i] === undefined ||
s[i] === '>' ||
s[i] === '<' ||
s[i] === '*' ||
s[i] === '?' ||
s[i] === '[' ||
s[i] === ']' ||
s[i] === '|' ||
s[i] === '˚' ||
s[i] === '$' ||
s[i] === ';' ||
s[i] === '&' ||
s[i] === ']' ||
s[i] === '#' ||
s[i] === '\\' ||
s[i] === '\t' ||
s[i] === '\n' ||
s[i] === '\r' ||
s[i] === '\'' ||
s[i] === '`' ||
s[i] === '"' ||
s[i].length > 1 ||
(strict && s[i] === '(') ||
(strict && s[i] === ')') ||
(strict && s[i] === '@') ||
(strict && s[i] === ' ') ||
(strict && s[i] == '{') ||
(strict && s[i] == ';') ||
(strict && s[i] == '}'))) {
if (
!(
s[i] === undefined ||
s[i] === '>' ||
s[i] === '<' ||
s[i] === '*' ||
s[i] === '?' ||
s[i] === '[' ||
s[i] === ']' ||
s[i] === '|' ||
s[i] === '˚' ||
s[i] === '$' ||
s[i] === ';' ||
s[i] === '&' ||
s[i] === ']' ||
s[i] === '#' ||
s[i] === '\\' ||
s[i] === '\t' ||
s[i] === '\n' ||
s[i] === '\r' ||
s[i] === "'" ||
s[i] === '`' ||
s[i] === '"' ||
s[i].length > 1 ||
(strict && s[i] === '(') ||
(strict && s[i] === ')') ||
(strict && s[i] === '@') ||
(strict && s[i] === ' ') ||
(strict && s[i] === '{') ||
(strict && s[i] === ';') ||
(strict && s[i] === '}')
)
) {
result = result + s[i];
}
}
@ -785,10 +803,10 @@ function isPrototypePolluted() {
} catch (e) {
Object.setPrototypeOf(st, stringObj);
}
notPolluted = notPolluted || (s.length !== 62);
notPolluted = notPolluted || s.length !== 62;
const ms = Date.now();
if (typeof ms === 'number' && ms > 1600000000000) {
const l = ms % 100 + 15;
const l = (ms % 100) + 15;
for (let i = 0; i < l; i++) {
const r = Math.random() * 61.99999999 + 1;
const rs = parseInt(Math.floor(r).toString(), 10);
@ -796,7 +814,7 @@ function isPrototypePolluted() {
const q = Math.random() * 61.99999999 + 1;
const qs = parseInt(Math.floor(q).toString(), 10);
const qs2 = parseInt(q.toString().split('.')[0], 10);
notPolluted = notPolluted && (r !== q);
notPolluted = notPolluted && r !== q;
notPolluted = notPolluted && rs === rs2 && qs === qs2;
st += s[rs - 1];
}
@ -826,7 +844,7 @@ function isPrototypePolluted() {
// lower
const stl = st.toLowerCase();
notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l]);
notPolluted = notPolluted && stl.length === l && stl[l - 1] && !stl[l];
for (let i = 0; i < l; i++) {
const s1 = st[i];
try {
@ -836,14 +854,14 @@ function isPrototypePolluted() {
}
const s2 = stl ? stl[i] : '';
const s1l = s1.toLowerCase();
notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !(s1l[1]);
notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !s1l[1];
}
}
return !notPolluted;
}
function hex2bin(hex) {
return ('00000000' + (parseInt(hex, 16)).toString(2)).substr(-8);
return ('00000000' + parseInt(hex, 16).toString(2)).substr(-8);
}
function getFilesInPath(source) {
@ -854,21 +872,35 @@ function getFilesInPath(source) {
function isDirectory(source) {
return lstatSync(source).isDirectory();
}
function isFile(source) { return lstatSync(source).isFile(); }
function isFile(source) {
return lstatSync(source).isFile();
}
function getDirectories(source) {
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isDirectory);
return readdirSync(source)
.map(function (name) {
return join(source, name);
})
.filter(isDirectory);
}
function getFiles(source) {
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isFile);
return readdirSync(source)
.map(function (name) {
return join(source, name);
})
.filter(isFile);
}
function getFilesRecursively(source) {
try {
let dirs = getDirectories(source);
let files = dirs
.map(function (dir) { return getFilesRecursively(dir); })
.reduce(function (a, b) { return a.concat(b); }, []);
.map(function (dir) {
return getFilesRecursively(dir);
})
.reduce(function (a, b) {
return a.concat(b);
}, []);
return files.concat(getFiles(source));
} catch (e) {
return [];
@ -883,7 +915,6 @@ function getFilesInPath(source) {
}
function decodePiCpuinfo(lines) {
if (_rpi_cpuinfo === null) {
_rpi_cpuinfo = lines;
} else if (lines === undefined) {
@ -1014,21 +1045,8 @@ function decodePiCpuinfo(lines) {
}
};
const processorList = [
'BCM2835',
'BCM2836',
'BCM2837',
'BCM2711',
'BCM2712',
];
const manufacturerList = [
'Sony UK',
'Egoman',
'Embest',
'Sony Japan',
'Embest',
'Stadium'
];
const processorList = ['BCM2835', 'BCM2836', 'BCM2837', 'BCM2711', 'BCM2712'];
const manufacturerList = ['Sony UK', 'Egoman', 'Embest', 'Sony Japan', 'Embest', 'Stadium'];
const typeList = {
'00': 'A',
'01': 'B',
@ -1044,17 +1062,17 @@ function decodePiCpuinfo(lines) {
'0d': '3B+',
'0e': '3A+',
'0f': 'Internal use only',
'10': 'CM3+',
'11': '4B',
'12': 'Zero 2 W',
'13': '400',
'14': 'CM4',
'15': 'CM4S',
'16': 'Internal use only',
'17': '5',
'18': 'CM5',
'19': '500/500+',
'1a': 'CM5 Lite',
10: 'CM3+',
11: '4B',
12: 'Zero 2 W',
13: '400',
14: 'CM4',
15: 'CM4S',
16: 'Internal use only',
17: '5',
18: 'CM5',
19: '500/500+',
'1a': 'CM5 Lite'
};
const revisionCode = getValue(lines, 'revision', ':', true);
@ -1072,9 +1090,8 @@ function decodePiCpuinfo(lines) {
manufacturer: oldRevisionCodes[revisionCode].manufacturer,
processor: oldRevisionCodes[revisionCode].processor,
type: oldRevisionCodes[revisionCode].type,
revision: oldRevisionCodes[revisionCode].revision,
revision: oldRevisionCodes[revisionCode].revision
};
} else {
// new revision code
const revision = ('00000000' + getValue(lines, 'revision', ':', true).toLowerCase()).substr(-8);
@ -1083,7 +1100,6 @@ function decodePiCpuinfo(lines) {
const processor = processorList[parseInt(revision.substr(4, 1), 10)];
const typeCode = revision.substr(5, 2);
result = {
model,
serial,
@ -1092,14 +1108,13 @@ function decodePiCpuinfo(lines) {
manufacturer,
processor,
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
revision: '1.' + revision.substr(7, 1),
revision: '1.' + revision.substr(7, 1)
};
}
return result;
}
function getRpiGpu(cpuinfo) {
if (_rpi_cpuinfo === null && cpuinfo !== undefined) {
_rpi_cpuinfo = cpuinfo;
} else if (cpuinfo === undefined && _rpi_cpuinfo !== null) {
@ -1114,8 +1129,12 @@ function getRpiGpu(cpuinfo) {
}
const rpi = decodePiCpuinfo(cpuinfo);
if (rpi.type === '4B' || rpi.type === 'CM4' || rpi.type === 'CM4S' || rpi.type === '400') { return 'VideoCore VI'; }
if (rpi.type === '5' || rpi.type === '500') { return 'VideoCore VII'; }
if (rpi.type === '4B' || rpi.type === 'CM4' || rpi.type === 'CM4S' || rpi.type === '400') {
return 'VideoCore VI';
}
if (rpi.type === '5' || rpi.type === '500') {
return 'VideoCore VII';
}
return 'VideoCore IV';
}
@ -1123,9 +1142,10 @@ function promiseAll(promises) {
const resolvingPromises = promises.map(function (promise) {
return new Promise(function (resolve) {
let payload = new Array(2);
promise.then(function (result) {
payload[0] = result;
})
promise
.then(function (result) {
payload[0] = result;
})
.catch(function (error) {
payload[1] = error;
})
@ -1139,23 +1159,22 @@ function promiseAll(promises) {
const results = [];
// Execute all wrapped Promises
return Promise.all(resolvingPromises)
.then(function (items) {
items.forEach(function (payload) {
if (payload[1]) {
errors.push(payload[1]);
results.push(null);
} else {
errors.push(null);
results.push(payload[0]);
}
});
return {
errors: errors,
results: results
};
return Promise.all(resolvingPromises).then(function (items) {
items.forEach(function (payload) {
if (payload[1]) {
errors.push(payload[1]);
results.push(null);
} else {
errors.push(null);
results.push(payload[0]);
}
});
return {
errors: errors,
results: results
};
});
}
function promisify(nodeStyleFunction) {
@ -1218,24 +1237,50 @@ function plistParser(xmlStr) {
while (pos < len) {
c = cn;
if (pos + 1 < len) { cn = xmlStr[pos + 1]; }
if (pos + 1 < len) {
cn = xmlStr[pos + 1];
}
if (c === '<') {
inTagContent = false;
if (cn === '/') { inTagEnd = true; }
else if (metaData[depth].tagStart) {
if (cn === '/') {
inTagEnd = true;
} else if (metaData[depth].tagStart) {
metaData[depth].tagContent = '';
if (!metaData[depth].data) { metaData[depth].data = metaData[depth].tagStart === 'array' ? [] : {}; }
if (!metaData[depth].data) {
metaData[depth].data = metaData[depth].tagStart === 'array' ? [] : {};
}
depth++;
metaData.push({ tagStart: '', tagEnd: '', tagContent: '', key: null, data: null });
inTagStart = true;
inTagContent = false;
} else if (!inTagStart) {
inTagStart = true;
}
else if (!inTagStart) { inTagStart = true; }
} else if (c === '>') {
if (metaData[depth].tagStart === 'true/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = true; }
if (metaData[depth].tagStart === 'false/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = false; }
if (metaData[depth].tagStart === 'array/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/arrayEmpty'; metaData[depth].data = []; }
if (inTagContent) { inTagContent = false; }
if (metaData[depth].tagStart === 'true/') {
inTagStart = false;
inTagEnd = true;
metaData[depth].tagStart = '';
metaData[depth].tagEnd = '/boolean';
metaData[depth].data = true;
}
if (metaData[depth].tagStart === 'false/') {
inTagStart = false;
inTagEnd = true;
metaData[depth].tagStart = '';
metaData[depth].tagEnd = '/boolean';
metaData[depth].data = false;
}
if (metaData[depth].tagStart === 'array/') {
inTagStart = false;
inTagEnd = true;
metaData[depth].tagStart = '';
metaData[depth].tagEnd = '/arrayEmpty';
metaData[depth].data = [];
}
if (inTagContent) {
inTagContent = false;
}
if (inTagStart) {
inTagStart = false;
inTagContent = true;
@ -1261,18 +1306,31 @@ function plistParser(xmlStr) {
metaData[depth].tagContent = '';
metaData[depth].tagStart = '';
metaData[depth].tagEnd = '';
}
else {
} else {
if (metaData[depth].tagEnd === '/key' && metaData[depth].tagContent) {
metaData[depth].key = metaData[depth].tagContent;
} else {
if (metaData[depth].tagEnd === '/real' && metaData[depth].tagContent) { metaData[depth].data = parseFloat(metaData[depth].tagContent) || 0; }
if (metaData[depth].tagEnd === '/integer' && metaData[depth].tagContent) { metaData[depth].data = parseInt(metaData[depth].tagContent) || 0; }
if (metaData[depth].tagEnd === '/string' && metaData[depth].tagContent) { metaData[depth].data = metaData[depth].tagContent || ''; }
if (metaData[depth].tagEnd === '/boolean') { metaData[depth].data = metaData[depth].tagContent || false; }
if (metaData[depth].tagEnd === '/arrayEmpty') { metaData[depth].data = metaData[depth].tagContent || []; }
if (depth > 0 && metaData[depth - 1].tagStart === 'array') { metaData[depth - 1].data.push(metaData[depth].data); }
if (depth > 0 && metaData[depth - 1].tagStart === 'dict') { metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data; }
if (metaData[depth].tagEnd === '/real' && metaData[depth].tagContent) {
metaData[depth].data = parseFloat(metaData[depth].tagContent) || 0;
}
if (metaData[depth].tagEnd === '/integer' && metaData[depth].tagContent) {
metaData[depth].data = parseInt(metaData[depth].tagContent) || 0;
}
if (metaData[depth].tagEnd === '/string' && metaData[depth].tagContent) {
metaData[depth].data = metaData[depth].tagContent || '';
}
if (metaData[depth].tagEnd === '/boolean') {
metaData[depth].data = metaData[depth].tagContent || false;
}
if (metaData[depth].tagEnd === '/arrayEmpty') {
metaData[depth].data = metaData[depth].tagContent || [];
}
if (depth > 0 && metaData[depth - 1].tagStart === 'array') {
metaData[depth - 1].data.push(metaData[depth].data);
}
if (depth > 0 && metaData[depth - 1].tagStart === 'dict') {
metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data;
}
}
metaData[depth].tagContent = '';
metaData[depth].tagStart = '';
@ -1284,9 +1342,15 @@ function plistParser(xmlStr) {
inTagContent = false;
}
} else {
if (inTagStart) { metaData[depth].tagStart += c; }
if (inTagEnd) { metaData[depth].tagEnd += c; }
if (inTagContent) { metaData[depth].tagContent += c; }
if (inTagStart) {
metaData[depth].tagStart += c;
}
if (inTagEnd) {
metaData[depth].tagEnd += c;
}
if (inTagContent) {
metaData[depth].tagContent += c;
}
}
pos++;
}
@ -1340,15 +1404,22 @@ function semverCompare(v1, v2) {
let res = 0;
const parts1 = v1.split('.');
const parts2 = v2.split('.');
if (parts1[0] < parts2[0]) { res = 1; }
else if (parts1[0] > parts2[0]) { res = -1; }
else if (parts1[0] === parts2[0] && parts1.length >= 2 && parts2.length >= 2) {
if (parts1[1] < parts2[1]) { res = 1; }
else if (parts1[1] > parts2[1]) { res = -1; }
else if (parts1[1] === parts2[1]) {
if (parts1[0] < parts2[0]) {
res = 1;
} else if (parts1[0] > parts2[0]) {
res = -1;
} else if (parts1[0] === parts2[0] && parts1.length >= 2 && parts2.length >= 2) {
if (parts1[1] < parts2[1]) {
res = 1;
} else if (parts1[1] > parts2[1]) {
res = -1;
} else if (parts1[1] === parts2[1]) {
if (parts1.length >= 3 && parts2.length >= 3) {
if (parts1[2] < parts2[2]) { res = 1; }
else if (parts1[2] > parts2[2]) { res = -1; }
if (parts1[2] < parts2[2]) {
res = 1;
} else if (parts1[2] > parts2[2]) {
res = -1;
}
} else if (parts2.length >= 3) {
res = 1;
}
@ -2522,10 +2593,18 @@ function getAppleModel(key) {
};
}
const features = [];
if (list[0].size) { features.push(list[0].size); }
if (list[0].processor) { features.push(list[0].processor); }
if (list[0].year) { features.push(list[0].year); }
if (list[0].additional) { features.push(list[0].additional); }
if (list[0].size) {
features.push(list[0].size);
}
if (list[0].processor) {
features.push(list[0].processor);
}
if (list[0].year) {
features.push(list[0].year);
}
if (list[0].additional) {
features.push(list[0].additional);
}
return {
key: key,
model: list[0].name,
@ -2534,12 +2613,12 @@ function getAppleModel(key) {
}
function checkWebsite(url, timeout = 5000) {
const http = ((url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0) ? require('https') : require('http'));
const http = url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0 ? require('https') : require('http');
const t = Date.now();
return new Promise((resolve) => {
const request = http
.get(url, function (res) {
res.on('data', () => { });
res.on('data', () => {});
res.on('end', () => {
resolve({
url,
@ -2549,7 +2628,7 @@ function checkWebsite(url, timeout = 5000) {
});
});
})
.on("error", function (e) {
.on('error', function (e) {
resolve({
url,
statusCode: 404,
@ -2567,12 +2646,12 @@ function checkWebsite(url, timeout = 5000) {
});
});
});
};
}
function cleanString(str) {
return str.replace(/To Be Filled By O.E.M./g, '');
}
function noop() { }
function noop() {}
exports.toInt = toInt;
exports.splitByNumber = splitByNumber;