Browse Source

Fixes ignoring of the escaped CR LF

Yury Delendik 11 years ago
parent
commit
20a91bcdbf
  1. 7
      src/core/parser.js
  2. 11
      test/unit/parser_spec.js

7
src/core/parser.js

@ -587,7 +587,12 @@ var Lexer = (function LexerClosure() {
strBuf.push(String.fromCharCode(x)); strBuf.push(String.fromCharCode(x));
break; break;
case 0x0A: case 0x0D: // LF, CR case 0x0D: // CR
if (this.peekChar() === 0x0A) { // LF
this.nextChar();
}
break;
case 0x0A: // LF
break; break;
default: default:
strBuf.push(String.fromCharCode(ch)); strBuf.push(String.fromCharCode(ch));

11
test/unit/parser_spec.js

@ -61,6 +61,17 @@ describe('parser', function() {
expect(result).toEqual('p!U"$2'); 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');
});
}); });
}); });

Loading…
Cancel
Save