FriendsOfFlarum / webhooks

Flarum with outgoing webhooks
MIT License
21 stars 12 forks source link

Sanitize post text #26

Closed ctml91 closed 3 years ago

ctml91 commented 3 years ago

It would be nice if there were a feature that could sanitize post content text that contains bbcode. For example, slack does not use bbcode so [color=#E0133F]A text string in a post that has been colored[/color], same would hold true for images, gifs, etc. I don't know what the best way to handle that would be, perhaps just remove everything between a set of brackets (including the brackets) and leave the content untouched (text, img links, etc) would make sense and may not add too much complexity.

dsevillamartin commented 3 years ago

I feel like removing BBCode is harder because it could just be tags that look like BBCode but aren't. I could convert into HTML and get the plain text from that... 🤔

mapleleafs89 commented 3 years ago

Hmm, would tags be available as a separate variable before it gets assembled together for the webhook? ie. Just sanitize the post text? Or do you mean there is a way to link to tags in a post using [tag] tag name [/tag]?

dsevillamartin commented 3 years ago

With tags I meant BBCode tags, like [bold], [img], etc. They would be available, technically, but it's more of a hassle to replace them.

I'm thinking I'll just attempt to convert the post HTML content to markdown or plain text - that's easier.

ctml91 commented 3 years ago

Sounds like a good solution to me!