Is there any available C++ (or maybe C) function/class/library with only purpose to sanitize a string that might contain HTML?
I find a lot of source code for sanitizing in C# or other languages more used in web application but nothing in C++.
I'll try to implement my own function if I don't find any available but I think an heavily tested solution would be far better.
edit> Some more precisions on my needs :
I'm getting text input from keyboard in my C++ application. Then I need to sanitize it before using it as a parameter in a javascript function call. That javascript run in a loaded html page that is automatically rendered (via Chromium) in a texture that I display via a library (Navi). So, the javascript function I use will simply take the given text, put P tag around the text and inject it in a div like this :
text_display.innerHTML += text_to_add;
I need to sanitize the text before sending it to the web page, be it for this function or another. It just have to be sanitized before input in Chromium.
HTML Tidy is written in c, but there are bindings for practically every language/platform, including c++.
You could use libxml2's xmlEncodeSpecialChars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With