String member functions assume list instead of char array like Adobe

Description

Lucee's has String.map() and String.each() as aliases for String.listMap() and String.listEach() – see this ticket
https://luceeserver.atlassian.net/browse/LDEV-388

However, this is causing compat issues with Adobe which treats a string as a char array when using the non-"list" version of the function. Also, Adobe has String.reduce() which Lucee does not support at all.

So in short, ONLY these methods should use list functionality:

  • String.listMap()

  • String.listEach()

  • String.listReduce()

And each of these should treat the string as a char array, looping over each character.

  • String.map()

  • String.each()

  • String.reduce()

Compare the behavior of each engine with the following snippet of code:

<ul> <cfscript> days = "1,3,5"; days.each( (i) => writeOutput( '<li>#i#</li>' ) ); </cfscript> </ul>

https://trycf.com/gist/2bfaeedd77f232a5cd6a018a73e9c13d/lucee5
https://trycf.com/gist/574ca56f850631764b7429ffb00f21b9/acf2021

 

Attachments

1
  • 20 Oct 2021, 04:59 pm

Activity

Show:

Pothys - MitrahSoft 4 May 2022 at 10:28

Now the string functions stringEach(), stringEvery(), stringFilter(), stringMap(), stringSome(), stringSort() and stringReduce() (as well as member functions) were added in lucee 6.0. I marked this ticket as deployed.

But those functions have incompatibility with ACF. Already I created a separate ticket for this issue ( https://luceeserver.atlassian.net/browse/LDEV-3772 )

Pothys - MitrahSoft 4 May 2022 at 08:32

I added a testcase to listFilter() and adjust some list functions testcases
Pull Request: https://github.com/lucee/Lucee/pull/1631

Michael Offner 29 April 2022 at 15:12

please adjust test cases for all this functions

Pothys - MitrahSoft 21 October 2021 at 10:01
Edited

I've checked this ticket and confirmed this issue happened on the lucee latest version 5.3.9.13-SNAPSHOT too. String member functions String.each(), String.every(), String.map(), String.some() treats the given string as a list instead of iterates over every character in the string. Also, lucee doesn't support the member functions String.filter(), String.sort().

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/resource/fld/core-base.fld#L459
https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/resource/fld/core-base.fld#L793
https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/resource/fld/core-base.fld#L12609
https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/resource/fld/core-base.fld#L12831

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 20 October 2021 at 16:56
Updated 8 June 2023 at 08:47
Resolved 4 May 2022 at 10:29

Flag notifications