Skip to content

Commit 8238580

Browse files
committed
fix: convert numeric character references representing < and & into &lt; and &amp;, as otherwise may break well-formedness; fixes svg#1
1 parent ef54995 commit 8238580

File tree

3 files changed

+9647
-2651
lines changed

3 files changed

+9647
-2651
lines changed

lib/sax.js

+6
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,12 @@
827827
num = parseInt(entity, 10)
828828
numStr = num.toString(10)
829829
}
830+
switch (num) {
831+
case 60: // '<'
832+
return '&lt;'
833+
case 38: // '&'
834+
return '&amp;'
835+
}
830836
}
831837
entity = entity.replace(/^0+/, '')
832838
if (isNaN(num) || numStr.toLowerCase() !== entity) {

0 commit comments

Comments
 (0)