Skip to content

Commit 612124c

Browse files
committed
fix(code-quality): drop regex lookbehind that Lucee's ORO engine rejects
Lucee routes to its ORO fallback, which throws "Sequence (?<...) not recognized" — surfaced by a live ERROR: run at $analyze. The debug-bar CodeComplexity.cfc carried the same latent pattern. Both now mask (so URL strings cannot be eaten) and strip line comments with a plain — valid in ORO, Java, and RustCFML engines. Verified on Lucee 7 against a sample with URLs, tag comments, block comments and code. Signed-off-by: Peter Amiri <peter@alurium.com>
1 parent 7a9f397 commit 612124c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

cli/lucli/services/coverage/CoverageService.cfc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ component output="false" {
3737
variables.tagDecision = "<" & "cf(?:if|elseif|loop|while|case|defaultcase|catch)" & variables.bs & "b";
3838
variables.tagComment = "<!---.*?--->";
3939
variables.blockComment = "/" & variables.bs & "*.*?" & variables.bs & "*/";
40-
variables.lineComment = "(?m)(?<!:)//[^" & variables.bs & "n]*";
40+
// No lookbehind here: Lucee routes such patterns to its ORO fallback,
41+
// which rejects `(?<!...)` ("Sequence (?<...) not recognized"). Mask
42+
// `://` first so a bare `//[^\r\n]*` cannot eat the tail of URL strings.
43+
variables.urlProtocol = "://";
44+
variables.lineComment = "//[^" & variables.bs & "r" & variables.bs & "n]*";
4145

4246
// Self-initializing counter, written into script function bodies. Single-
4347
// quoted so the embedded double quotes need no escaping.
@@ -183,6 +187,7 @@ component output="false" {
183187
private string function $stripComments(required string text) {
184188
local.rv = reReplace(arguments.text, variables.tagComment, "", "all");
185189
local.rv = reReplace(local.rv, variables.blockComment, "", "all");
190+
local.rv = reReplace(local.rv, variables.urlProtocol, "__WHEELS_PROTO__", "all");
186191
local.rv = reReplace(local.rv, variables.lineComment, "", "all");
187192
return local.rv;
188193
}

vendor/wheels/wheelstest/system/CodeComplexity.cfc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ component output="false" {
3737
variables.scriptFn = variables.wb & "function" & variables.ws & "+[A-Za-z_$][" & variables.ww & "$]*" & variables.ws & "*" & variables.bs & "(";
3838
variables.tagFn = "<" & "cffunction" & variables.wb & "[^>]*?" & variables.wb & "name";
3939
variables.blockComment = "/" & variables.bs & "*.*?" & variables.bs & "*/";
40-
variables.lineComment = "(?m)(?<!:)//[^" & variables.nn & "]*";
40+
// No lookbehind here: Lucee routes such patterns to its ORO fallback,
41+
// which rejects `(?<!...)` ("Sequence (?<...) not recognized"). Mask
42+
// `://` first so a bare `//[^\r\n]*` cannot eat the tail of URL strings.
43+
variables.urlProtocol = "://";
44+
variables.lineComment = "//[^" & variables.bs & "r" & variables.bs & "n]*";
4145
variables.tagComment = "<!---.*?--->";
4246

4347
/**
@@ -114,6 +118,7 @@ component output="false" {
114118
public string function $stripComments(required string text) {
115119
local.rv = reReplace(arguments.text, variables.tagComment, "", "all");
116120
local.rv = reReplace(local.rv, variables.blockComment, "", "all");
121+
local.rv = reReplace(local.rv, variables.urlProtocol, "__WHEELS_PROTO__", "all");
117122
local.rv = reReplace(local.rv, variables.lineComment, "", "all");
118123
return local.rv;
119124
}

0 commit comments

Comments
 (0)