Skip to content

Commit

Permalink
LDEV-4892 - fixing regression with function listener
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jun 10, 2024
1 parent 54c4774 commit 5e66506
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ private FunctionMember getFunctionMember(Data data, final ExprString name, boole
}

private Expression getListener(Data data) throws TemplateException {
if (!insideCase && tenaryContext != CTX_TENARY_MIDDLE && data.srcCode.forwardIfCurrent(':')) {
if (!insideCase && tenaryContext != CTX_TENARY_MIDDLE && data.srcCode.isPreviousIgnoreSpace(')') && data.srcCode.forwardIfCurrent(':')) {
int pos = data.srcCode.getPos();
comments(data);
Expression expr = assignOp(data);
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/lucee/transformer/util/SourceCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ public boolean isPrevious(char c) {
return lcText[pos - 1] == c;
}

public boolean isPreviousIgnoreSpace(char c) {
int start = pos;
try {
while (isPrevious(' ')) {
pos--;
}
if (!hasPrevious()) return false;
return charAt(getPos() - 1) == c;
}
finally {
pos = start;
}
}

/**
* is the character at the next position the same as the character provided by the input parameter
*/
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.1.0.190-SNAPSHOT"/>
<property name="version" value="6.1.0.191-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.1.0.190-SNAPSHOT</version>
<version>6.1.0.191-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down
21 changes: 21 additions & 0 deletions test/tickets/LDEV4892.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {
function test() {
return "abc";
}
function run( testResults, testBox ) {
describe("Testcase for LDEV-4892 - Invalid struct shorthand syntax", function() {
it( title="check syntax colon with space", body=function( currentSpec ) {
var x={ "#test()#" : function(){} };
});
it( title="check syntax colon no space", body=function( currentSpec ) {
var x={ "#test()#":function(){} };
});
it( title="check syntax colon no space", body=function( currentSpec ) {
var x={ "#test()#" = function(){} };
});
it( title="check syntax colon no space", body=function( currentSpec ) {
var x={ "#test()#"=function(){} };
});
});
}
}

0 comments on commit 5e66506

Please sign in to comment.