From 2e91cf8e0367694df7eb13f3556296d0be16363a Mon Sep 17 00:00:00 2001 From: Aylur Date: Wed, 2 Aug 2023 18:16:07 +0200 Subject: [PATCH] stricter name filter --- src/service/mpris.ts | 4 ++-- src/service/notifications.ts | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/service/mpris.ts b/src/service/mpris.ts index bf0d2eb..a71320e 100644 --- a/src/service/mpris.ts +++ b/src/service/mpris.ts @@ -131,8 +131,8 @@ class MprisPlayer extends GObject.Object { _cacheCoverArt() { this.coverPath = MEDIA_CACHE_PATH + '/' + - `${this.trackArtists.join(', ')} - ${this.trackTitle}` - .replace(/[\,\*\?\"\<\>\|\#\:\?\/\'\(\)]/g, ''); + `${this.trackArtists.join(', ')}${this.trackTitle}` + .replace(/[^a-zA-Z0-9]/g, ''); if (this.coverPath.length > 255) this.coverPath = this.coverPath.substring(0, 255); diff --git a/src/service/notifications.ts b/src/service/notifications.ts index f7f54e0..c922d87 100644 --- a/src/service/notifications.ts +++ b/src/service/notifications.ts @@ -180,13 +180,6 @@ class NotificationsService extends Service { ); } - _filterName(name: string) { - return NOTIFICATIONS_CACHE_PATH + - '/' + - name.replace(/[\ \,\*\?\"\<\>\|\#\:\?\/\!\']/g, '') + - '.png'; - } - _readFromFile() { const file = readFile(NOTIFICATIONS_CACHE_PATH + '/notifications.json'); if (!file) @@ -212,7 +205,7 @@ class NotificationsService extends Service { return null; ensureDirectory(); - const fileName = this._filterName(name); + const fileName = name.replace(/[^a-zA-Z0-9]/g, ''); const image = image_data.recursiveUnpack(); const pixbuf = GdkPixbuf.Pixbuf.new_from_bytes( image[6],