Fix to remove non-terminated character references
Related-to: remarkjs/remark#913.
This commit is contained in:
parent
ff45db552e
commit
7301073466
2 changed files with 32 additions and 3 deletions
|
@ -131,7 +131,12 @@ export function directiveHtml(options = {}) {
|
|||
/** @type {Attribute[]} */
|
||||
// @ts-expect-error
|
||||
const attributes = this.getData('directiveAttributes')
|
||||
attributes.push(['id', parseEntities(this.sliceSerialize(token))])
|
||||
attributes.push([
|
||||
'id',
|
||||
parseEntities(this.sliceSerialize(token), {
|
||||
attribute: true
|
||||
})
|
||||
])
|
||||
}
|
||||
|
||||
/** @type {_Handle} */
|
||||
|
@ -140,7 +145,12 @@ export function directiveHtml(options = {}) {
|
|||
// @ts-expect-error
|
||||
const attributes = this.getData('directiveAttributes')
|
||||
|
||||
attributes.push(['class', parseEntities(this.sliceSerialize(token))])
|
||||
attributes.push([
|
||||
'class',
|
||||
parseEntities(this.sliceSerialize(token), {
|
||||
attribute: true
|
||||
})
|
||||
])
|
||||
}
|
||||
|
||||
/** @type {_Handle} */
|
||||
|
@ -160,7 +170,8 @@ export function directiveHtml(options = {}) {
|
|||
// @ts-expect-error
|
||||
const attributes = this.getData('directiveAttributes')
|
||||
attributes[attributes.length - 1][1] = parseEntities(
|
||||
this.sliceSerialize(token)
|
||||
this.sliceSerialize(token),
|
||||
{attribute: true}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1347,6 +1347,24 @@ test('content', (t) => {
|
|||
'should support unknown character references in attribute values'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
micromark(':a{href=¶m}', options({'*': h})),
|
||||
'<p><a href="&param"></a></p>',
|
||||
'should not support non-terminated character references in unquoted attribute values'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
micromark(':a{href="¶m"}', options({'*': h})),
|
||||
'<p><a href="&param"></a></p>',
|
||||
'should not support non-terminated character references in double quoted attribute values'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
micromark(":a{href='¶m'}", options({'*': h})),
|
||||
'<p><a href="&param"></a></p>',
|
||||
'should not support non-terminated character references in single quoted attribute values'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
micromark(':span{a\nb}', options({'*': h})),
|
||||
'<p><span a="" b=""></span></p>',
|
||||
|
|
Loading…
Add table
Reference in a new issue