Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit length of single fields in notification #332

Merged
merged 1 commit into from
Jul 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Text and icons are now centred vertically
- Notifications aren't considered duplicate if urgency or icons differ
- The frame width and color settings were moved to the global section as frame\_width and frame\_color respectively.
- The maximum displayed field length is limited to 5000 characters

### Deprecated
- `allow_markup` will be removed in later versions. It is being replaced by `markup`
Expand Down
10 changes: 10 additions & 0 deletions src/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ int notification_init(notification * n, int id)

n->msg = g_strchomp(n->msg);

/* truncate overlong messages */
if (strlen(n->msg) > DUNST_NOTIF_MAX_CHARS) {
char* buffer = g_malloc(DUNST_NOTIF_MAX_CHARS);
strncpy(buffer, n->msg, DUNST_NOTIF_MAX_CHARS);
buffer[DUNST_NOTIF_MAX_CHARS-1] = '\0';

g_free(n->msg);
n->msg = buffer;
}

if (n->icon != NULL && strlen(n->icon) <= 0) {
g_free(n->icon);
n->icon = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#define NORM 1
#define CRIT 2

#define DUNST_NOTIF_MAX_CHARS 5000

typedef struct _raw_image {
int width;
int height;
Expand Down