diff --git a/client/src/features/reader/epub/components/DictionaryPopover.vue b/client/src/features/reader/epub/components/DictionaryPopover.vue index 213e7f0fd..abb6339f4 100644 --- a/client/src/features/reader/epub/components/DictionaryPopover.vue +++ b/client/src/features/reader/epub/components/DictionaryPopover.vue @@ -1,8 +1,8 @@ ', examples: [] }], @@ -341,13 +715,48 @@ describe('useDictionary', () => { const def = result!.entries[0]!.definitions[0]!.definition expect(def).not.toContain('') - expect(def).toContain('Normal text.') + expect(def).not.toContain('alert(1)') + expect(def).toBe('Normal text.') + }) + + it('Wiktionary: strips inline style blocks rather than rendering their CSS', async () => { + fetchMock.mockResolvedValueOnce( + mockOk({ + fr: [ + { + partOfSpeech: 'Verb', + definitions: [ + { + definition: 'Used to express evaluations [with complement].', + examples: [], + }, + ], + }, + ], + }), + ) + const { lookup } = await load() + const result = await lookup('fare', 'fr') + + expect(result!.entries[0]!.definitions[0]!.definition).toBe('Used to express evaluations [with complement].') + }) + + it('Wiktionary: collapses newlines and runs of whitespace inside a definition', async () => { + fetchMock.mockResolvedValueOnce( + mockOk({ + fr: [{ partOfSpeech: 'Noun', definitions: [{ definition: 'A greeting\n\n used daily.', examples: [] }] }], + }), + ) + const { lookup } = await load() + const result = await lookup('hi', 'fr') + + expect(result!.entries[0]!.definitions[0]!.definition).toBe('A greeting used daily.') }) it('Wiktionary: handles partial/unclosed HTML tags that old regex could not strip', async () => { fetchMock.mockResolvedValueOnce( mockOk({ - en: [ + fr: [ { partOfSpeech: 'Noun', definitions: [{ definition: '