mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Fix unicode parsing Close #56
This commit is contained in:
parent
a36964799b
commit
ff52f47537
2 changed files with 12 additions and 7 deletions
|
|
@ -170,6 +170,10 @@ function lex(text, parseStrings){
|
|||
if (escape) {
|
||||
if (ch == 'u') {
|
||||
var hex = text.substring(index + 1, index + 5);
|
||||
if (!hex.match(/[\da-f]{4}/i))
|
||||
throw "Lexer Error: Invalid unicode escape [\\u" +
|
||||
hex + "] starting at column '" +
|
||||
start + "' in expression '" + text + "'.";
|
||||
index += 4;
|
||||
string += String.fromCharCode(parseInt(hex, 16));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
desccribe('parser', function(){
|
||||
describe('parser', function(){
|
||||
describe('lexer', function(){
|
||||
it('should TokenizeAString', function(){
|
||||
var tokens = lex("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
|
||||
|
|
@ -170,6 +170,13 @@ desccribe('parser', function(){
|
|||
var tokens = lex(".5");
|
||||
expect(tokens[0].text).toEqual(0.5);
|
||||
});
|
||||
|
||||
it('should throw error on invalid unicode', function(){
|
||||
assertThrows("Lexer Error: Invalid unicode escape [\\u1''b] starting at column '0' in expression ''\\u1''bla''.", function(){
|
||||
lex("'\\u1''bla'");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should parse Expressions', function(){
|
||||
|
|
@ -400,12 +407,6 @@ desccribe('parser', function(){
|
|||
assertEquals('misko', scope.$eval('n'));
|
||||
});
|
||||
|
||||
it('should parse FiltersCanBeGrouped', function () {
|
||||
var scope = createScope({name:'MISKO'});
|
||||
assertEquals('misko', scope.$eval('n = (name|lowercase)'));
|
||||
assertEquals('misko', scope.$eval('n'));
|
||||
});
|
||||
|
||||
it('should parse Remainder', function () {
|
||||
var scope = createScope();
|
||||
assertEquals(1, scope.$eval('1%2'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue