[Pkg-javascript-commits] [pdf.js] 144/174: Improve error message for non-existent local files

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:36 UTC 2015


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

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

commit c604cc22d17d544ed084dfd512c7223903a94f93
Author: Rob Wu <rob at robwu.nl>
Date:   Sun Nov 8 18:03:28 2015 +0100

    Improve error message for non-existent local files
    
    I received multiple reports about the following cryptic error in the
    Chrome extension when the user tried to open a local file:
    
    > PDF.js v1.1.527 (build: 2096a2a)
    > Message: Cannot read property 'Symbol(Symbol.iterator)' of null
    
    This error most likely originated from core/stream.js:
    
        function Stream(arrayBuffer, start, length, dict) {
          this.bytes = (arrayBuffer instanceof Uint8Array ?
                        arrayBuffer : new Uint8Array(arrayBuffer));
                                                     ^^^^^^^^^^^
    `arrayBuffer` is `null`, and that in turn is caused by the fact that
    for non-existing files, there is no data. I've applied two fixes:
    
    1. Never call onDone with a void buffer, but call the error handler
       instead.
    2. Show a sensible error message for local files with status = 0.
---
 src/core/network.js | 4 +++-
 src/core/worker.js  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/core/network.js b/src/core/network.js
index 8100303..c39dc06 100644
--- a/src/core/network.js
+++ b/src/core/network.js
@@ -245,11 +245,13 @@ var NetworkManager = (function NetworkManagerClosure() {
         });
       } else if (pendingRequest.onProgressiveData) {
         pendingRequest.onDone(null);
-      } else {
+      } else if (chunk) {
         pendingRequest.onDone({
           begin: 0,
           chunk: chunk
         });
+      } else if (pendingRequest.onError) {
+        pendingRequest.onError(xhr.status);
       }
     },
 
diff --git a/src/core/worker.js b/src/core/worker.js
index 728ed3a..74ff464 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -236,7 +236,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
 
         onError: function onError(status) {
           var exception;
-          if (status === 404) {
+          if (status === 404 || status === 0 && /^file:/.test(source.url)) {
             exception = new MissingPDFException('Missing PDF "' +
                                                 source.url + '".');
             handler.send('MissingPDF', exception);

-- 
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