mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
Strip null
(\x00) characters from the URLs in LinkAnnotations (issue 6832)
Apparently some PDF files can have annotations with `URI` entries ending with `null` characters, thus breaking the links. To handle this edge-case of bad PDFs, this patch moves the already existing utility function from `ui_utils.js` into `util.js`, in order to fix those URLs. Fixes 6832.
This commit is contained in:
parent
4e9ea35eee
commit
97c10e9c08
7 changed files with 33 additions and 25 deletions
|
@ -33,6 +33,7 @@ var AnnotationType = sharedUtil.AnnotationType;
|
|||
var Util = sharedUtil.Util;
|
||||
var isExternalLinkTargetSet = sharedUtil.isExternalLinkTargetSet;
|
||||
var LinkTargetStringMap = sharedUtil.LinkTargetStringMap;
|
||||
var removeNullCharacters = sharedUtil.removeNullCharacters;
|
||||
var warn = sharedUtil.warn;
|
||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||
|
||||
|
@ -232,7 +233,8 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
|
|||
this.container.className = 'linkAnnotation';
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.href = link.title = this.data.url || '';
|
||||
link.href = link.title = (this.data.url ?
|
||||
removeNullCharacters(this.data.url) : '');
|
||||
|
||||
if (this.data.url && isExternalLinkTargetSet()) {
|
||||
link.target = LinkTargetStringMap[PDFJS.externalLinkTarget];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue