[Pkg-javascript-commits] [pdf.js] 92/161: Fixes ignoring of the escaped CR LF

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 14:16:33 UTC 2014


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

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

commit 20a91bcdbfb3430a9e842ee2fb609062c9266b44
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Thu Mar 20 11:50:12 2014 -0500

    Fixes ignoring of the escaped CR LF
---
 src/core/parser.js       |  7 ++++++-
 test/unit/parser_spec.js | 11 +++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/core/parser.js b/src/core/parser.js
index 0eb62c5..205a34c 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -587,7 +587,12 @@ var Lexer = (function LexerClosure() {
 
                 strBuf.push(String.fromCharCode(x));
                 break;
-              case 0x0A: case 0x0D: // LF, CR
+              case 0x0D: // CR
+                if (this.peekChar() === 0x0A) { // LF
+                  this.nextChar();
+                }
+                break;
+              case 0x0A: // LF
                 break;
               default:
                 strBuf.push(String.fromCharCode(ch));
diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js
index fdab17a..e03cdd9 100644
--- a/test/unit/parser_spec.js
+++ b/test/unit/parser_spec.js
@@ -61,6 +61,17 @@ describe('parser', function() {
 
       expect(result).toEqual('p!U"$2');
     });
+
+    it('should ignore escaped CR and LF', function() {
+      // '(\101\<CR><LF>\102)'
+      // should be parsed as
+      // "AB"
+      var input = new StringStream('(\\101\\\r\n\\102\\\r\\103\\\n\\104)');
+      var lexer = new Lexer(input);
+      var result = lexer.getString();
+
+      expect(result).toEqual('ABCD');
+    });
   });
 });
 

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