Hi,
as I saw the release of Lucee 5.3.8 I was curious if I could upgrade one of my servers to the new version.
while testing I noticed that REFind throws an error when using it with the scope="all"
option.
Context
I am searching for uppercase letters in a String via REFind with the expression reg_expression="[A-Z]"
Bug
After some testing I noticed that the error only occures when the REFind does not find any matches. In Lucee 5.3.7 the result of the REFind statement is 0 in this case. As shown in my test below this also applies to string.REFind
Code
try{ local.testStr = "teststring12e"; local.testStr.reFind( reg_expression = "[A-Z]", scope = "all" ); } catch( any e ) { writeDump( '"teststring12e" FAILED' ); }
try{ reFind( reg_expression = "[A-Z]", string = "teststring12e", scope = "all" ); } catch( any e ) { writeDump( '"teststring12e" FAILED' ); }
try{ writeDump( reFind( reg_expression = "[A-Z]", string = "Teststring12e", scope = "all" ) ); } catch( any e ) { writeDump( '"Teststring12e" FAILED' ); }
try{ writeDump( reFind( reg_expression = "[A-Z]", string = "testString12e", scope = "all" ) ); } catch( any e ) { writeDump( '"testString12e" FAILED' ); }
try{ writeDump( reFind( reg_expression = "[A-Z]", string = "TestString12E", scope = "all" ) ); } catch( any e ) { writeDump( '"TestString12E" FAILED' ); }
Expected Output: None
Actual Output:
"teststring12e" FAILED
"teststring12e" FAILED
Stack Trace
lucee.runtime.exp.CasterException: Can't cast Object type [Number] to a value of type [Array] at lucee.runtime.op.Caster.toArray(Caster.java:2408) at lucee.runtime.regex.Perl5Regex.indexOfAll(Perl5Regex.java:55) at lucee.runtime.functions.string.REFind.call(REFind.java:59) at <Usage in Code>
Sincerely, Christian
OS: macOS 11.4
Java Version: 1.8.0_291
Lucee Version: 5.3.8.189