1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Merge pull request #10457 from Snuffleupagus/metadata-tests

When parsing Metadata, attempt to remove "junk" before the first tag (PR 10398 follow-up)
This commit is contained in:
Tim van der Meij 2019-01-16 23:03:39 +01:00 committed by GitHub
commit cdbc33ba06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 2 deletions

View file

@ -35,7 +35,9 @@ class Metadata {
}
_repair(data) {
return data.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
// Start by removing any "junk" before the first tag (see issue 10395).
return data.replace(/^([^<]+)/, '').replace(/>\\376\\377([^<]+)/g,
function(all, codes) {
let bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
function(code, d1, d2, d3) {
return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
@ -104,7 +106,8 @@ class Metadata {
}
get(name) {
return this._metadata[name] || null;
const data = this._metadata[name];
return (typeof data !== 'undefined' ? data : null);
}
getAll() {