Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that an A entry in an annotation dictionary is also a dictionary itself #5684

Merged
merged 1 commit into from Jan 31, 2015

Conversation

timvandermeij
Copy link
Contributor

Fixes #5683.

According to https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=647&zoom=auto,-246,56 an A entry in an annotation dictionary must also be a dictionary itself. The current code just assumes that, but some (corrupted) PDFs violate that standard. This patch makes sure to check that the A entry is actually a dictionary before trying to get properties from it (on https://github.com/mozilla/pdf.js/blob/master/src/core/annotation.js#L489 which assumes we are dealing with a valid dictionary).

@@ -485,7 +485,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
data.annotationType = AnnotationType.LINK;

var action = dict.get('A');
if (action) {
if (isDict(action)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about if (action && isDict(action)) { instead, to avoid doing the isDict check if action isn't defined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats the first check in isDict. so what you actually only avoid is the method call to that util function. there are many more instances were we prefer the util method cal over the trivial implementation inside.
like

function isArray(v) {
  return v instanceof Array;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it would be better to avoid the function call here if possible. The commit has been updated.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/2ed10b36db86831/output.txt

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/919571647424b9c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/c6fa37413ccf83d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/c6fa37413ccf83d/output.txt

Total script time: 2.88 mins

  • Font tests: FAILED
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.22.172.223:8877/c6fa37413ccf83d/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/919571647424b9c/output.txt

Total script time: 22.72 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

Snuffleupagus added a commit that referenced this pull request Jan 31, 2015
Make sure that an A entry in an annotation dictionary is also a dictionary itself
@Snuffleupagus Snuffleupagus merged commit 294c4a8 into mozilla:master Jan 31, 2015
@Snuffleupagus
Copy link
Collaborator

Seems fine, thanks!

@timvandermeij timvandermeij deleted the link-annotation-bug branch January 31, 2015 14:04
speedplane pushed a commit to speedplane/pdf.js that referenced this pull request Feb 24, 2015
Make sure that an A entry in an annotation dictionary is also a dictionary itself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error reported when rendering pdf
4 participants