]> git.parisson.com Git - pdf.js.git/commitdiff
Add protection against malicious code in font loader.
authorKalervo Kujala <kkujala@com>
Tue, 20 Mar 2012 15:56:42 +0000 (17:56 +0200)
committerKalervo Kujala <kkujala@com>
Tue, 20 Mar 2012 15:57:38 +0000 (17:57 +0200)
src/fonts.js

index c1023f6fca800f3aed5fa08f8827972d1ad9f877..6b89068271824c8c4da26273490e03edc32d7f7d 100644 (file)
@@ -494,9 +494,14 @@ var FontLoader = {
       // 82402.
 
       // Validate the names parameter -- the values can used to construct HTML.
-      if (!/^\w+$/.test(names.join('')))
+      if (!/^\w+$/.test(names.join(''))) {
         error('Invalid font name(s): ' + names.join());
 
+        // Normally the error-function throws. But if a malicious code
+        // intercepts the function call then the return is needed.
+        return;
+      }
+
       var div = document.createElement('div');
       div.setAttribute('style',
                        'visibility: hidden;' +