disable markup by default, escape string and resolve escaped html
This commit is contained in:
parent
5813e0053b
commit
3031723315
|
@ -103,6 +103,7 @@ public:
|
|||
* Returns application specific hints:
|
||||
* Key | Value | Required
|
||||
* ------------- | ----------- | -----------
|
||||
* use-markup | Enable markup support for title and message, strings must be html escaped.| Many Backends.
|
||||
* desktop-entry | The name of the desktop enty associated with the application. | Used for The freedesktop backend.
|
||||
* windows-app-id | The app id associated with the application. | Needed for the Windows 8 backend [See MSDN Documentation](http://msdn.microsoft.com/en-us/library/windows/apps/dd378459.aspx).
|
||||
* tray-icon | A pointer to a QSystemTray item. | Needed for the System Tray Backend.
|
||||
|
|
|
@ -26,6 +26,7 @@ ApplicationData::ApplicationData(const QString &name, const Icon &icon):
|
|||
{
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "invalid name detected");
|
||||
m_hint.setValue("pushover-token", "aFB1TPCyZkkr7mubCGEKy5vJEWak9t");
|
||||
m_hint.setValue("use-markup", QVariant::fromValue(false));
|
||||
}
|
||||
|
||||
ApplicationData::~ApplicationData()
|
||||
|
|
|
@ -94,12 +94,20 @@ const Application &Notification::application() const
|
|||
|
||||
QString Notification::title(Utils::MARKUP_FLAGS flags) const
|
||||
{
|
||||
if(!application().constHints().value("use-markup").toBool()) {
|
||||
return d->m_title.toHtmlEscaped();
|
||||
} else {
|
||||
return Utils::normaliseMarkup(d->m_title, flags);
|
||||
}
|
||||
}
|
||||
|
||||
QString Notification::text(Utils::MARKUP_FLAGS flags) const
|
||||
{
|
||||
if(!application().constHints().value("use-markup").toBool()) {
|
||||
return d->m_text.toHtmlEscaped();
|
||||
}else {
|
||||
return Utils::normaliseMarkup(d->m_text, flags);
|
||||
}
|
||||
}
|
||||
|
||||
const Alert &Notification::alert() const
|
||||
|
@ -204,8 +212,6 @@ QDebug operator <<(QDebug debug, const Snore::Notification::CloseReasons &flags)
|
|||
debugPrintEnum(Notification::DISMISSED);
|
||||
debugPrintEnum(Notification::ACTIVATED);
|
||||
debugPrintEnum(Notification::REPLACED);
|
||||
default:
|
||||
debug << QByteArray::number(flags, 16) << ")";
|
||||
}
|
||||
return debug.space();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include <QRegExp>
|
||||
#include <QMutex>
|
||||
#include <QTextDocument>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
|
@ -81,6 +83,11 @@ QString Utils::normaliseMarkup(QString string, MARKUP_FLAGS tags)
|
|||
static QMutex mutex;
|
||||
if(tags == ALL_MARKUP){
|
||||
return string;
|
||||
} else if(tags == NO_MARKUP) {
|
||||
if (Qt::mightBeRichText(string)) {
|
||||
return QTextDocumentFragment::fromHtml(string).toPlainText();
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
QMutexLocker lock(&mutex);
|
||||
|
|
|
@ -44,8 +44,9 @@ void Pushover::slotNotify(Notification notification)
|
|||
|
||||
QHttpPart text;
|
||||
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"message\""));
|
||||
text.setBody(notification.text(Utils::HREF | Utils::BOLD | Utils::UNDERLINE | Utils::FONT | Utils::ITALIC)
|
||||
.toUtf8().constData());
|
||||
QString textString = notification.text(Utils::HREF | Utils::BOLD | Utils::UNDERLINE | Utils::FONT | Utils::ITALIC);
|
||||
snoreDebug(SNORE_DEBUG) << "Message" << textString;
|
||||
text.setBody(textString.toUtf8().constData());
|
||||
mp->append(text);
|
||||
|
||||
QHttpPart priority;
|
||||
|
|
Loading…
Reference in New Issue