From d2187d0ace952f5c56199e0b172d6962efed5ab4 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 24 May 2021 22:04:41 +0200 Subject: [PATCH] [db] Partially revert commit aaffa4a so that source sort tags are used again Fix for issue #1257 --- src/db.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index 613ba3fa..73a40809 100644 --- a/src/db.c +++ b/src/db.c @@ -907,7 +907,21 @@ sort_tag_create(char **sort_tag, const char *src_tag) /* Note: include terminating NUL in string length for u8_normalize */ - free(*sort_tag); + // If the source provides a source tag then we rely on a normalized version of + // that instead of creating our own (see issue #1257). FIXME this produces the + // following bug: + // - Track with no sort tags, assume queue_item->artist is "A", then + // queue_item->artist_sort will be created and set to "A". + // - Update the artist name of the queue item with JSON API to "B". + // - queue_item->artist_sort will still be "A". + if (*sort_tag) + { + DPRINTF(E_DBG, L_DB, "Existing sort tag will be normalized: %s\n", *sort_tag); + o_ptr = u8_normalize(UNINORM_NFD, (uint8_t *)*sort_tag, strlen(*sort_tag) + 1, NULL, &len); + free(*sort_tag); + *sort_tag = (char *)o_ptr; + return; + } if (!src_tag || ((len = strlen(src_tag)) == 0)) {