Fix to properly parse character references
This commit is contained in:
parent
9029e1ccc0
commit
063e6651ad
1 changed files with 4 additions and 24 deletions
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import {decodeEntity} from 'parse-entities/decode-entity.js'
|
import {parseEntities} from 'parse-entities'
|
||||||
|
|
||||||
const own = {}.hasOwnProperty
|
const own = {}.hasOwnProperty
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ export function directiveHtml(options = {}) {
|
||||||
/** @type {Attribute[]} */
|
/** @type {Attribute[]} */
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const attributes = this.getData('directiveAttributes')
|
const attributes = this.getData('directiveAttributes')
|
||||||
attributes.push(['id', decodeLight(this.sliceSerialize(token))])
|
attributes.push(['id', parseEntities(this.sliceSerialize(token))])
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {_Handle} */
|
/** @type {_Handle} */
|
||||||
|
@ -140,7 +140,7 @@ export function directiveHtml(options = {}) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const attributes = this.getData('directiveAttributes')
|
const attributes = this.getData('directiveAttributes')
|
||||||
|
|
||||||
attributes.push(['class', decodeLight(this.sliceSerialize(token))])
|
attributes.push(['class', parseEntities(this.sliceSerialize(token))])
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {_Handle} */
|
/** @type {_Handle} */
|
||||||
|
@ -159,7 +159,7 @@ export function directiveHtml(options = {}) {
|
||||||
/** @type {Attribute[]} */
|
/** @type {Attribute[]} */
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const attributes = this.getData('directiveAttributes')
|
const attributes = this.getData('directiveAttributes')
|
||||||
attributes[attributes.length - 1][1] = decodeLight(
|
attributes[attributes.length - 1][1] = parseEntities(
|
||||||
this.sliceSerialize(token)
|
this.sliceSerialize(token)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -240,23 +240,3 @@ export function directiveHtml(options = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} value
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function decodeLight(value) {
|
|
||||||
return value.replace(
|
|
||||||
/&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi,
|
|
||||||
decodeIfPossible
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} $0
|
|
||||||
* @param {string} $1
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function decodeIfPossible($0, $1) {
|
|
||||||
return decodeEntity($1) || $0
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue