Skip to content

Commit c4ae414

Browse files
committed
encode less-than signs in text context after whitespace
1 parent ee3b345 commit c4ae414

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/unsafe.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ export const unsafe = [
109109
inConstruct: 'phrasing',
110110
notInConstruct: fullPhrasingSpans
111111
},
112+
{
113+
character: '<',
114+
before: '(?:[ \t\r\n]|$)',
115+
inConstruct: 'phrasing',
116+
notInConstruct: fullPhrasingSpans
117+
},
112118
{character: '<', inConstruct: 'destinationLiteral'},
113119
// An equals to can start setext heading underlines.
114120
{atBreak: true, character: '='},

test/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3932,6 +3932,26 @@ test('escape', async function (t) {
39323932
)
39333933
})
39343934

3935+
await t.test(
3936+
'should escape what would otherwise be html (2)',
3937+
async function () {
3938+
assert.equal(
3939+
to({type: 'paragraph', children: [{type: 'text', value: '<1%'}]}),
3940+
'\\<1%\n'
3941+
)
3942+
}
3943+
)
3944+
3945+
await t.test(
3946+
'dont escape a less-than sign that cant be a tag open',
3947+
async function () {
3948+
assert.equal(
3949+
to({type: 'paragraph', children: [{type: 'text', value: 'm<1%'}]}),
3950+
'm<1%\n'
3951+
)
3952+
}
3953+
)
3954+
39353955
await t.test(
39363956
'should escape what would otherwise be code (text)',
39373957
async function () {

0 commit comments

Comments
 (0)