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:
commit
11b56ad0f7
24
web/app.js
24
web/app.js
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user