Skip to content

Commit

Permalink
Add test case about HTML injection for rendering <figcaption>
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 9, 2023
1 parent 33240f9 commit a4318b3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/markdown/background_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ describe('Marpit background image plugin', () => {
![bg fit The background image](A)
![This is bg 20% w:40% xxxxx](B)
![ bg ](C)
![bg <b>should <br /> escape</b>](D)
`),
)
const figures = $('figure')
Expand All @@ -222,7 +223,14 @@ describe('Marpit background image plugin', () => {
)
expect(figures.eq(1).is(':has(figcaption)')).toBe(true)
expect(figures.eq(1).find('figcaption').text()).toBe('This is xxxxx')

// Ignore whitespaces
expect(figures.eq(2).is(':has(figcaption)')).toBe(false)

// XSS
expect(figures.eq(3).is(':has(figcaption)')).toBe(true)
expect(figures.eq(3).is(':has(b)')).toBe(false)
expect(figures.eq(3).is(':has(br)')).toBe(false)
})

it('assigns background-size style with resizing keyword / scale', () => {
Expand Down

0 comments on commit a4318b3

Please sign in to comment.