mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Detect plain text plists
This commit is contained in:
parent
4ee5076098
commit
0d519bbb46
1 changed files with 10 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
// Adpapted for browser+node from https://github.com/joeferner/node-bplist-parser/blob/master/bplistParser.js
|
// Adpapted for browser+node from https://github.com/joeferner/node-bplist-parser/blob/master/bplistParser.js
|
||||||
|
import plainTextPlist from 'plist'
|
||||||
import bigInt from 'big-integer'
|
import bigInt from 'big-integer'
|
||||||
import bufferApi from 'buffer'
|
import bufferApi from 'buffer'
|
||||||
|
|
||||||
|
|
@ -62,6 +63,15 @@ export function parseFileSync (fileNameOrBuffer) {
|
||||||
function parseBuffer ( buffer ) {
|
function parseBuffer ( buffer ) {
|
||||||
// check header
|
// check header
|
||||||
const header = buffer.slice(0, 'bplist'.length).toString('utf8');
|
const header = buffer.slice(0, 'bplist'.length).toString('utf8');
|
||||||
|
|
||||||
|
const isPlainTextPlist = header.includes('<?xml')
|
||||||
|
|
||||||
|
if ( isPlainTextPlist ) {
|
||||||
|
// console.log( 'isPlainTextPlist', isPlainTextPlist )
|
||||||
|
|
||||||
|
return plainTextPlist.parse( buffer.toString('utf8') )
|
||||||
|
}
|
||||||
|
|
||||||
if (header !== 'bplist') {
|
if (header !== 'bplist') {
|
||||||
throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
|
throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue