[Pkg-javascript-commits] [pdf.js] 111/210: Handle more cases of invalid line dash patterns in annotation borders

David Prévot taffit at moszumanska.debian.org
Thu Jun 5 14:21:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch upstream
in repository pdf.js.

commit 67a3b5986403575fe891b9507f1a91eceebf581f
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri May 9 23:12:23 2014 +0200

    Handle more cases of invalid line dash patterns in annotation borders
---
 src/shared/annotation.js | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/shared/annotation.js b/src/shared/annotation.js
index 3d6510f..af3fa9f 100644
--- a/src/shared/annotation.js
+++ b/src/shared/annotation.js
@@ -105,24 +105,30 @@ var Annotation = (function AnnotationClosure() {
 
       // TODO: implement proper support for annotations with line dash patterns.
       var dashArray = borderArray[3];
-      if (data.borderWidth > 0 && dashArray && isArray(dashArray)) {
-        var dashArrayLength = dashArray.length;
-        if (dashArrayLength > 0) {
-          // According to the PDF specification: the elements in a dashArray
-          // shall be numbers that are nonnegative and not all equal to zero.
-          var isInvalid = false;
-          var numPositive = 0;
-          for (var i = 0; i < dashArrayLength; i++) {
-            var validNumber = (+dashArray[i] >= 0);
-            if (!validNumber) {
-              isInvalid = true;
-              break;
-            } else if (dashArray[i] > 0) {
-              numPositive++;
+      if (data.borderWidth > 0 && dashArray) {
+        if (!isArray(dashArray)) {
+          // Ignore the border if dashArray is not actually an array,
+          // this is consistent with the behaviour in Adobe Reader. 
+          data.borderWidth = 0;
+        } else {
+          var dashArrayLength = dashArray.length;
+          if (dashArrayLength > 0) {
+            // According to the PDF specification: the elements in a dashArray
+            // shall be numbers that are nonnegative and not all equal to zero.
+            var isInvalid = false;
+            var numPositive = 0;
+            for (var i = 0; i < dashArrayLength; i++) {
+              var validNumber = (+dashArray[i] >= 0);
+              if (!validNumber) {
+                isInvalid = true;
+                break;
+              } else if (dashArray[i] > 0) {
+                numPositive++;
+              }
+            }
+            if (isInvalid || numPositive === 0) {
+              data.borderWidth = 0;
             }
-          }
-          if (isInvalid || numPositive === 0) {
-            data.borderWidth = 0;
           }
         }
       }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list