File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ function HtmlToDom(parser) {
63
63
var parserInstance = new parser . Parser ( handler , {
64
64
xmlMode : isXML ,
65
65
lowerCaseTags : ! isXML ,
66
- lowerCaseAttributeNames : ! isXML
66
+ lowerCaseAttributeNames : ! isXML ,
67
+ decodeEntities : true
67
68
} ) ;
68
69
69
70
parserInstance . includeLocation = false ;
@@ -175,10 +176,8 @@ function setChild(parent, node) {
175
176
break ;
176
177
177
178
case 'text' :
178
- // Decode HTML entities if we're not inside a <script> or <style> tag:
179
- newNode = currentDocument . createTextNode ( / ^ (?: s c r i p t | s t y l e ) $ / i. test ( parent . nodeName ) ?
180
- node . data :
181
- HTMLDecode ( node . data ) ) ;
179
+ // HTML entities should already be decoded by the parser, so no need to decode them
180
+ newNode = currentDocument . createTextNode ( node . data ) ;
182
181
break ;
183
182
184
183
case 'comment' :
@@ -198,7 +197,7 @@ function setChild(parent, node) {
198
197
// catchin errors here helps with improperly escaped attributes
199
198
// but properly fixing parent should (can only?) be done in the htmlparser itself
200
199
try {
201
- newNode . setAttribute ( c , HTMLDecode ( node . attribs [ c ] ) ) ;
200
+ newNode . setAttribute ( c , node . attribs [ c ] ) ;
202
201
} catch ( e2 ) { /* noop */ }
203
202
}
204
203
}
You can’t perform that action at this time.
0 commit comments