Update regex and mapped usernames to handle bug relating to map order
What does this MR do and why?
This change updates the regex and mapped_usernames to handle cases where username mapping fails due to the order of keys in the map. Here we ensure the mapped_usernames are sorted by length, then when substituting via the regex we append an @ symbol before each string to ensure that only usernames are replaced.
See #413623 (comment 1553848989) for further discussion
Specs have been amended to test the described failure.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #413623 (closed)