@@ -193,17 +193,57 @@ function $InterpolateProvider() {
193
193
textLength = text . length ,
194
194
exp ,
195
195
concat = [ ] ,
196
- expressionPositions = [ ] ;
196
+ expressionPositions = [ ] ,
197
+ state = 0 ,
198
+ brackets = { "(" : 0 , ")" : 0 , "{" : 0 , "}" : 0 , "[" : 0 , "]" : 0 } ,
199
+ bracketChars = "(){}[]" ,
200
+ ch ,
201
+ i ;
197
202
198
203
while ( index < textLength ) {
199
204
if ( ( ( startIndex = text . indexOf ( startSymbol , index ) ) != - 1 ) &&
200
205
( ( endIndex = text . indexOf ( endSymbol , startIndex + startSymbolLength ) ) != - 1 ) ) {
201
206
if ( index !== startIndex ) {
202
207
concat . push ( unescapeText ( text . substring ( index , startIndex ) ) ) ;
203
208
}
209
+ index = startIndex + startSymbolLength ;
210
+ while ( index !== endIndex || state !== 0 || brackets [ '(' ] !== brackets [ ')' ] ||
211
+ brackets [ '[' ] !== brackets [ ']' ] || brackets [ '{' ] !== brackets [ '}' ] ) {
212
+ if ( index === endIndex ) {
213
+ endIndex = text . indexOf ( endSymbol , endIndex + 1 ) ;
214
+ if ( endIndex === - 1 ) {
215
+ break ;
216
+ }
217
+ }
218
+ ch = text [ index ] ;
219
+ switch ( state ) {
220
+ case 0 :
221
+ if ( ch === "'" ) state = 1 ;
222
+ if ( ch === '"' ) state = 3 ;
223
+ if ( ( i = bracketChars . indexOf ( ch ) ) != - 1 ) {
224
+ brackets [ ch ] ++ ;
225
+ }
226
+ break ;
227
+ case 1 :
228
+ if ( ch === '\\' ) state = 2 ;
229
+ if ( ch === "'" ) state = 0 ;
230
+ break ;
231
+ case 2 :
232
+ state = 1 ;
233
+ break ;
234
+ case 3 :
235
+ if ( ch === '\\' ) state = 4 ;
236
+ if ( ch === '"' ) state = 0 ;
237
+ break ;
238
+ case 4 :
239
+ state = 3 ;
240
+ break ;
241
+ }
242
+ index ++ ;
243
+ }
204
244
exp = text . substring ( startIndex + startSymbolLength , endIndex ) ;
205
- expressions . push ( exp ) ;
206
245
parseFns . push ( $parse ( exp , parseStringifyInterceptor ) ) ;
246
+ expressions . push ( exp ) ;
207
247
index = endIndex + endSymbolLength ;
208
248
expressionPositions . push ( concat . length ) ;
209
249
concat . push ( '' ) ;
0 commit comments