Merge pull request #11423 from Snuffleupagus/bug-1605526

Ignore Metadata entries with incorrectly encoded characters, when setting the viewer title (bug 1605526)
This commit is contained in:
Tim van der Meij 2019-12-24 22:44:31 +01:00 committed by GitHub
commit 11b56ad0f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1117,16 +1117,22 @@ let PDFViewerApplication = {
(AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
let pdfTitle;
if (metadata && metadata.has('dc:title')) {
let title = metadata.get('dc:title');
// Ghostscript sometimes return 'Untitled', sets the title to 'Untitled'
if (title !== 'Untitled') {
pdfTitle = title;
}
}
if (!pdfTitle && info && info['Title']) {
pdfTitle = info['Title'];
const infoTitle = info && info['Title'];
if (infoTitle) {
pdfTitle = infoTitle;
}
const metadataTitle = metadata && metadata.get('dc:title');
if (metadataTitle) {
// Ghostscript can produce invalid 'dc:title' Metadata entries:
// - The title may be "Untitled" (fixes bug 1031612).
// - The title may contain incorrectly encoded characters, which thus
// looks broken, hence we ignore the Metadata entry when it contains
// characters from the Specials Unicode block (fixes bug 1605526).
if (metadataTitle !== 'Untitled' &&
!/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
pdfTitle = metadataTitle;
}
}
if (pdfTitle) {