mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-10 13:54:16 +00:00
properly escape media info payload
This commit is contained in:
parent
7021a98615
commit
6ff8ffabef
1 changed files with 14 additions and 6 deletions
20
src/media.m
20
src/media.m
|
@ -58,10 +58,14 @@ bool g_media_events = false;
|
|||
- (void) update {
|
||||
@autoreleasepool {
|
||||
if (self.app && self.artist && self.title && self.album) {
|
||||
char* escaped_artist = escape_string((char*)self.artist);
|
||||
char* escaped_title = escape_string((char*)self.title);
|
||||
char* escaped_album = escape_string((char*)self.album);
|
||||
|
||||
uint32_t info_len = strlen(self.app)
|
||||
+ strlen(self.artist)
|
||||
+ strlen(self.title)
|
||||
+ strlen(self.album) + 256;
|
||||
+ strlen(escaped_artist)
|
||||
+ strlen(escaped_title)
|
||||
+ strlen(escaped_album) + 256;
|
||||
|
||||
char info[info_len];
|
||||
snprintf(info, info_len, "{\n"
|
||||
|
@ -71,11 +75,15 @@ bool g_media_events = false;
|
|||
"\t\"artist\": \"%s\",\n"
|
||||
"\t\"app\": \"%s\"\n}",
|
||||
self.playing ? "playing" : "paused",
|
||||
self.title,
|
||||
self.album,
|
||||
self.artist,
|
||||
escaped_title,
|
||||
escaped_album,
|
||||
escaped_artist,
|
||||
self.app );
|
||||
|
||||
free(escaped_artist);
|
||||
free(escaped_title);
|
||||
free(escaped_album);
|
||||
|
||||
if (self.artwork) {
|
||||
struct event cover_event = { self.artwork, COVER_CHANGED };
|
||||
event_post(&cover_event);
|
||||
|
|
Loading…
Reference in a new issue