File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,11 +142,11 @@ export function compile(node: ExpressionNode): string | number | boolean | null
142142 ? `(typeof ${ compile ( target ) } === '${ typeName } ')`
143143 : `Function.prototype[Symbol.hasInstance].call(${ assertIdentifier ( typeName ) } , ${ compile ( target ) } )`
144144 } else if ( type === 'ref' ) {
145- const refValue = value as string
145+ const refValue = assertIdentifier ( value as string )
146146 if ( refValue . startsWith ( '@' ) ) {
147147 return `$dd_${ refValue . slice ( 1 ) } `
148148 }
149- return assertIdentifier ( refValue )
149+ return refValue
150150 } else if ( Array . isArray ( value ) ) {
151151 const args = value . map ( ( v ) => compile ( v as ExpressionNode ) )
152152 switch ( type ) {
Original file line number Diff line number Diff line change @@ -121,6 +121,26 @@ export const references: TestCase[] = [
121121 expected : new SyntaxError ( 'Illegal identifier: throw new Error()' ) ,
122122 execute : false ,
123123 } ,
124+ {
125+ ast : { ref : '@x; throw new Error("injected"); //' } ,
126+ expected : new SyntaxError ( 'Illegal identifier: @x; throw new Error("injected"); //' ) ,
127+ execute : false ,
128+ } ,
129+ {
130+ ast : { ref : '@x.y' } ,
131+ expected : new SyntaxError ( 'Illegal identifier: @x.y' ) ,
132+ execute : false ,
133+ } ,
134+ {
135+ ast : { ref : '@x-y' } ,
136+ expected : new SyntaxError ( 'Illegal identifier: @x-y' ) ,
137+ execute : false ,
138+ } ,
139+ {
140+ ast : { ref : '@(1)' } ,
141+ expected : new SyntaxError ( 'Illegal identifier: @(1)' ) ,
142+ execute : false ,
143+ } ,
124144]
125145
126146export const propertyAccess : TestCase [ ] = [
You can’t perform that action at this time.
0 commit comments