How do I escape/sanitize a QString that contains HTML?
I.e. showInBroswser(escaped(str)) == showInNotepad(str);
Use QString::toHtmlEscaped()
QString src; Qstring html = src.toHtmlEscaped(); showInBrowser(html) == showInNotepad(str);
Reference: http://doc.qt.io/qt-5/qstring.html#toHtmlEscaped
Use Qt::escape
.
#include <QtGui/qtextdocument.h> QString src; Qstring html = Qt::escape(src); showInBrowser(html) == showInNotepad(str);
Reference: http://doc.qt.io/qt-4.8/qt.html#escape
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