bplist-parser
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -15,9 +15,6 @@ 'use strict'; | ||
var parseFile = exports.parseFile = function (fileName, callback) { | ||
fs.readFile(fileName, function (err, data) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
var parseFile = exports.parseFile = function (fileNameOrBuffer, callback) { | ||
function tryParseBuffer(buffer) { | ||
try { | ||
var result = parseBuffer(data); | ||
var result = parseBuffer(buffer); | ||
return callback(null, result); | ||
@@ -27,3 +24,12 @@ } catch (ex) { | ||
} | ||
}); | ||
} | ||
if (Buffer.isBuffer(fileNameOrBuffer)) { | ||
return tryParseBuffer(fileNameOrBuffer); | ||
} else { | ||
fs.readFile(fileNameOrBuffer, function (err, data) { | ||
if (err) { return callback(err); } | ||
tryParseBuffer(data); | ||
}); | ||
} | ||
}; | ||
@@ -88,4 +94,5 @@ | ||
case 0x1: | ||
case 0x8: // UID (really just an integer) | ||
return parseInteger(); | ||
case 0x8: | ||
return parseUID(); | ||
case 0x2: | ||
@@ -134,2 +141,11 @@ return parseReal(); | ||
function parseUID() { | ||
var length = objInfo + 1; | ||
if (length < exports.maxObjectSize) { | ||
return readUInt(buffer.slice(offset + 1, offset + 1 + length)); | ||
} else { | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
} | ||
function parseReal() { | ||
@@ -208,3 +224,3 @@ var length = Math.pow(2, objInfo); | ||
if (isUtf16) { | ||
plistString = swapBytes(plistString); | ||
plistString = swapBytes(plistString); | ||
enc = "ucs2"; | ||
@@ -314,2 +330,2 @@ } | ||
return buffer; | ||
} | ||
} |
{ | ||
"name": "bplist-parser", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Binary plist parser.", | ||
@@ -5,0 +5,0 @@ "main": "bplistParser.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
43588
396
0