bugfix JSON.parse error blockDevices()

This commit is contained in:
Sebastian Hildebrandt 2017-11-01 21:24:33 +01:00
parent e628237f53
commit de45423289
3 changed files with 11 additions and 0 deletions

View File

@ -99,6 +99,8 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.32.2 | 2017-10-23 | bugfix JSON.parse error `blockDevices()` |
| 3.32.1 | 2017-10-23 | updated docs |
| 3.32.0 | 2017-10-23 | extended `memLayout()` - added manufacturer |
| 3.31.4 | 2017-10-21 | updated `README.md` |
| 3.31.3 | 2017-10-21 | bugfix `graphics()`, fixed typo `README.md` |

View File

@ -151,6 +151,7 @@ function parseBlk(lines) {
let data = [];
lines.filter(line => line !== '').forEach((line) => {
line = util.decodeEscapeSequence(line);
line = line.replace(/\\/g,'\\\\');
let disk = JSON.parse(line);
data.push({

View File

@ -79,8 +79,16 @@ function getValue(lines, property, separator, trimmed) {
return '';
}
function decodeEscapeSequence(str, base) {
base = base || 16
return str.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
return String.fromCharCode(parseInt(arguments[1], base));
});
};
exports.isFunction = isFunction;
exports.unique = unique;
exports.sortByKey= sortByKey;
exports.cores = cores;
exports.getValue = getValue;
exports.decodeEscapeSequence = decodeEscapeSequence;