Skip to content

Commit 4031a9d

Browse files
authored
Merge pull request #88 from trufae/parse-hard
Be more strict when parsing plists
2 parents 64c2fbf + be43f31 commit 4031a9d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: ci
22

33
on:
44
push:
5+
pull_request:
56

67
jobs:
78
build:

lib/parse.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,7 @@ function parsePlistXML (node) {
220220

221221
} else if (node.nodeName === 'false') {
222222
return false;
223+
} else {
224+
throw new Error('Invalid PLIST tag ' + node.nodeName);
223225
}
224226
}

test/parse.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,4 +519,30 @@ int main(int argc, char *argv[])
519519
});
520520
});
521521
});
522+
describe('invalid formats', function () {
523+
it('should fail parsing invalid xml plist', function () {
524+
var xml = multiline(function () {
525+
/*
526+
<?xml version="1.0" encoding="UTF-8"?>
527+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
528+
<plist version="1.0">
529+
<dict>
530+
<key>test</key>
531+
<strong>Testing</strong>
532+
<key>bar</key>
533+
<string></string>
534+
</dict>
535+
</plist>
536+
*/
537+
});
538+
assert.throws(function () {
539+
var parsed = parse(xml);
540+
});
541+
});
542+
it('ensure empty strings arent valid plist', function () {
543+
assert.throws(function () {
544+
var parsed = parse('');
545+
});
546+
});
547+
});
522548
});

0 commit comments

Comments
 (0)