]> git.parisson.com Git - pdf.js.git/commitdiff
Handle junk at the end of postscript functions.
authorBrendan Dahl <brendan.dahl@gmail.com>
Wed, 18 Apr 2012 16:48:28 +0000 (09:48 -0700)
committerBrendan Dahl <brendan.dahl@gmail.com>
Wed, 18 Apr 2012 16:48:28 +0000 (09:48 -0700)
src/function.js
test/unit/function_spec.js

index 2e7ad45e6ea3842a7c4563eb9176542a93f16b71..d16805b52c0620a269789d1b31932e91b596dfaf 100644 (file)
@@ -836,7 +836,10 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
       // operator
       var str = ch.toLowerCase();
       while (true) {
-        ch = stream.lookChar().toLowerCase();
+        ch = stream.lookChar();
+        if (ch === null)
+          break;
+        ch.toLowerCase();
         if (ch >= 'a' && ch <= 'z')
           str += ch;
         else
index 2a1dc0b75a4ebf8be9673096d1b1a56b7342c699..94240c47df4863f13774bacd6db2c1135c308b96 100644 (file)
@@ -77,6 +77,12 @@ describe('function', function() {
       expect(function() { parse('{'); }).toThrow(
                   new Error('Unexpected symbol: found undefined expected 1.'));
     });
+    it('handles junk after the end', function() {
+      var number = 3.3;
+      var program = parse('{ ' + number + ' }#');
+      var expectedProgram = [number];
+      expect(program).toMatchArray(expectedProgram);
+    });
   });
 
   describe('PostScriptEvaluator', function() {