Can The Server Action Strip Tags Function Accept a Whitelist?

I have text from a summernote input field that I want to santise in my server action.

I’d like to be able to have all the HTML tags stripped except for an allowed list.

In PHP, I can do it like this:

$input = strip_tags($input, '<b><i><a>');

It looks like the Wappler strip_tags function doesn’t take any parameters to allow this… is this the case?

Would I need to write my own PHP function to do this?

Thanks!
Antony.

The strip tags formatter, removes all the html tags from a string, it does not support lists of tags to be removed.

@Antony

Something like that?
image

Used the replace formatter n times .
n= array.length() contaning the tags that you will define…
image

  • I used an array list because I didn’t know how to assign a static array like:
    ["<b>", "</b>", "<a>", "</a>", "<i>", "</i>"]
    You can do that I suppose :wink:

I want to strip all tags except the ones in the list, so this wouldn’t work!

I used an array list because I didn’t know how to assign a static array like:

You can use split.

1 Like