Replace via a struct inserts gibberish when struct keys not found in text

Description

When trying to replace text via a struct, but certain keys are not found in the text gibberish characters are inserted.

<cfscript> writeDump(var= replace("one string, two strings, three strings", {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}), label="replace via a struct" ); </cfscript>

This results in

￿￿￿ string, ￿￿￿ strings, ￿￿￿￿￿ strings

Environment

None

Attachments

2
  • 20 Nov 2021, 02:05 am
  • 20 Nov 2021, 02:03 am

Activity

Show:

Pothys - MitrahSoft 30 May 2023 at 06:49

I’ve checked this issue with both lucee versions 5.4.0.61-SNAPSHOT & 6.0.0.413-SNAPSHOT. Now when trying to replace text via a struct using the replace(), it works fine and gives correct results

Michael Offner 26 May 2023 at 15:02

no backport to 5.3, no security issue

Zac Spitzer 26 May 2023 at 13:35

if you are happy with this, I’ll backport to 5.3 and 5.4 after it’s merged

Zac Spitzer 26 May 2023 at 10:28

add a boolean to track if any matches and then create a string builder to do the replace

https://github.com/lucee/Lucee/pull/2081

Fixed

Details

Assignee

Reporter

Priority

Fix versions

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

Affects versions

Created 20 November 2021 at 02:04
Updated 30 May 2023 at 06:49
Resolved 30 May 2023 at 06:49

Flag notifications