summaryrefslogtreecommitdiffstats
path: root/journal-notify.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-07-02 23:46:12 +0200
committerGravatar Christian Hesse <mail@eworm.de>2014-07-02 23:46:12 +0200
commitf24c0d1a1655d152d7a2ac07faa7ecf6119ac7c7 (patch)
tree40b151b89f686209257694b54cd0f63316fe560c /journal-notify.c
parent05b11c5931dfd261c9d05e28a39c65eaf7c568dd (diff)
downloadjournal-notify-f24c0d1a1655d152d7a2ac07faa7ecf6119ac7c7.tar.gz
journal-notify-f24c0d1a1655d152d7a2ac07faa7ecf6119ac7c7.tar.zst
make sure text is escaped
Diffstat (limited to 'journal-notify.c')
-rw-r--r--journal-notify.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/journal-notify.c b/journal-notify.c
index 7e78232..d3951ff 100644
--- a/journal-notify.c
+++ b/journal-notify.c
@@ -37,7 +37,7 @@ int main(int argc, char **argv) {
size_t length;
char * summary, * message;
- const char *summarystr, * messagestr, * icon = DEFAULTICON;
+ const char * icon = DEFAULTICON;
program = argv[0];
@@ -132,24 +132,22 @@ int main(int argc, char **argv) {
continue;
}
- message = strndup(data, length);
- messagestr = message + 8;
+ message = g_markup_escape_text(data + 8, length - 8);
/* get SYSLOG_IDENTIFIER field */
if ((rc = sd_journal_get_data(journal, "SYSLOG_IDENTIFIER", &data, &length)) < 0) {
fprintf(stderr, "Failed to read syslog identifier field: %s\n", strerror(-rc));
continue;
}
- summary = strndup(data, length);
- summarystr = summary + 18;
+ summary = g_markup_escape_text(data + 18, length - 18);
/* show notification */
if (have_regex > 0) {
- if (regexec(&regex, messagestr, 0, NULL, 0) == 0) {
- notify(summarystr, messagestr, icon);
+ if (regexec(&regex, message, 0, NULL, 0) == 0) {
+ notify(summary, message, icon);
}
} else {
- notify(summarystr, messagestr, icon);
+ notify(summary, message, icon);
}
free(summary);