Hi Clifford
Thanks for the feedback. This is Juan, Toolset development team leader. I would like to try to clarify this question.
As a default, we follow the WordPress standards. There is a capability named "unfiltered_html", which grants a reserved set of users the ability to post, and save, whatever content they want, without any restriction on HTML tags used, including script tags:
https://wordpress.org/support/article/roles-and-capabilities/#unfiltered_html
By default, this capability is only granted to admins (only to superadmins if the site is a multisite instalation). Those roles can indeed save script tags in post content, so they can also do it on our fields, and we do not run any safety check on them.
Our fields follow the same principle as WordPress for users without that unfiltered_html capability. In fact, if you add the same content directly to a post and save it, the script tag wil get removed and the encoded script tag will be kept. Because, as a principle, encoded tags are just characters and not actual tags that can or should be removed.
We include a setting in Toolset -> Settings -> Custom content -> Saving unfiltered HTML for users with higher roles, that allows you to be more restrictive: it bypasses the capability and removes the ability to save unfiltered HTML in our fields even if the current user can do that for native post content.
There is a list of HTML tags that users with restrictions can use. It is not totally straightforward to craft, but this core function should help:
https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/
This of course means that some tags are indeed allowed in multiple line fields, by default and for all users. Any HTML that is valid for post content as per WordPress restrctions, is also valid for fields content, based on the current user role and capabilities. Bold, italic, etc... those elements are available as valid content to save.
Following your example, I see that data is safely stored and safely printed, unless you manually manipulate it and decode its entities. While I understand this might sound dangerous, whatever you do manually with the data is up to you: you could as well append a string printing a script to it. But the data in custom fields, multiple or single line fields, is safely stored and safely printed by default, following the same principles as data stored and printed in post content.
Now, should we also remove encoded unsupported tags? Well, WordPress itself does not do that on the post content, and I understand that there are legitimate usages for that encoded content. You might want to use a field to store a code snippet for example. Or some syntax in a language that is not HTML but is also tag-based. So in my opinion we should not restrict further what you can and can not include in your fields, given that the security level is the same as for the post content.
I hope this helps and mitigates the security concerns. Please let me know if I can help you with anything else.
Regards.