From 7915202b333b637c561d084457f6dd0c55392e82 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Thu, 14 Dec 2023 15:18:53 +0100 Subject: [PATCH 1/2] 109964: Always encode the vocabulary stored value Not encoding this value broke stored values containing trailing slashes and some special characters --- src/app/core/submission/vocabularies/vocabulary.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/submission/vocabularies/vocabulary.service.ts b/src/app/core/submission/vocabularies/vocabulary.service.ts index da58512441d..0d5f7063305 100644 --- a/src/app/core/submission/vocabularies/vocabulary.service.ts +++ b/src/app/core/submission/vocabularies/vocabulary.service.ts @@ -192,7 +192,7 @@ export class VocabularyService { getVocabularyEntriesByValue(value: string, exact: boolean, vocabularyOptions: VocabularyOptions, pageInfo: PageInfo): Observable>> { const options: VocabularyFindOptions = new VocabularyFindOptions( null, - value, + encodeURIComponent(value), exact, null, pageInfo.elementsPerPage, From 989b7f592bdd17dedc5456a192cbf530de807398 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Thu, 28 Dec 2023 16:36:55 +0100 Subject: [PATCH 2/2] 109728: Added test to check that getVocabularyEntriesByValue encodes its value --- .../vocabularies/vocabulary.service.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/core/submission/vocabularies/vocabulary.service.spec.ts b/src/app/core/submission/vocabularies/vocabulary.service.spec.ts index 9f8bec307f2..f6fac9edb58 100644 --- a/src/app/core/submission/vocabularies/vocabulary.service.spec.ts +++ b/src/app/core/submission/vocabularies/vocabulary.service.spec.ts @@ -365,6 +365,18 @@ describe('VocabularyService', () => { }) })); }); + + it('should encode the value', () => { + scheduler.schedule(() => service.getVocabularyEntriesByValue('https://creativecommons.org/licenses/by-sa/4.0/', false, vocabularyOptions, pageInfo).subscribe()); + scheduler.flush(); + + expect(service.findVocabularyById).toHaveBeenCalledWith(vocabularyOptions.name, true, true, jasmine.objectContaining({ + findListOptions: jasmine.objectContaining({ + filter: 'https%3A%2F%2Fcreativecommons.org%2Flicenses%2Fby-sa%2F4.0%2F', + exact: false, + }) + })); + }); }); describe('getVocabularyEntryByValue', () => {