@xmldom/xmldom 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.7.6](https://github.com/xmldom/xmldom/compare/0.7.5...0.7.6)
8
+
9
+ ### Fixed
10
+ - Avoid iterating over prototype properties [`#441`](https://github.com/xmldom/xmldom/pull/441) / [`#437`](https://github.com/xmldom/xmldom/pull/437) / [`#436`](https://github.com/xmldom/xmldom/issues/436)
11
+
12
+ Thank you, [@jftanner](https://github.com/jftanner), [@Supraja9726](https://github.com/Supraja9726) for your contributions
13
+
14
+ ## 0.7.5
15
+
16
+ [Commits](https://github.com/xmldom/xmldom/compare/0.7.4...0.7.5)
17
+
18
+ ### Fixes:
19
+
20
+ - Preserve default namespace when serializing [`#319`](https://github.com/xmldom/xmldom/issues/319) / [`#321`](https://github.com/xmldom/xmldom/pull/321)
21
+ Thank you, [@lupestro](https://github.com/lupestro)
22
+
7
23
  ## 0.7.4
8
24
 
9
25
  [Commits](https://github.com/xmldom/xmldom/compare/0.7.3...0.7.4)
@@ -11,7 +27,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
11
27
  ### Fixes:
12
28
 
13
29
  - Restore ability to parse `__prototype__` attributes [`#315`](https://github.com/xmldom/xmldom/pull/315)
14
- Thank you [@dsimsonOMF](https://github.com/dsimsonOMF)
30
+ Thank you, [@dsimpsonOMF](https://github.com/dsimpsonOMF)
15
31
 
16
32
  ## 0.7.3
17
33
 
@@ -21,7 +37,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
21
37
 
22
38
  - Add doctype when parsing from string [`#277`](https://github.com/xmldom/xmldom/issues/277) / [`#301`](https://github.com/xmldom/xmldom/pull/301)
23
39
  - Correct typo in error message [`#294`](https://github.com/xmldom/xmldom/pull/294)
24
- Thank you [@rrthomas](https://github.com/rrthomas)
40
+ Thank you, [@rrthomas](https://github.com/rrthomas)
25
41
 
26
42
  ### Refactor:
27
43
 
@@ -46,7 +62,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
46
62
  ### Fixes:
47
63
 
48
64
  - Types: Add index.d.ts to packaged files [`#288`](https://github.com/xmldom/xmldom/pull/288)
49
- Thank you [@forty](https://github.com/forty)
65
+ Thank you, [@forty](https://github.com/forty)
50
66
 
51
67
  ## 0.7.1
52
68
 
@@ -55,7 +71,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
55
71
  ### Fixes:
56
72
 
57
73
  - Types: Copy types from DefinitelyTyped [`#283`](https://github.com/xmldom/xmldom/pull/283)
58
- Thank you [@kachkaev](https://github.com/kachkaev)
74
+ Thank you, [@kachkaev](https://github.com/kachkaev)
59
75
 
60
76
  ### Chore:
61
77
  - package.json: remove author, maintainers, etc. [`#279`](https://github.com/xmldom/xmldom/pull/279)
@@ -72,7 +88,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
72
88
  ### Fixes:
73
89
 
74
90
  - Security: Misinterpretation of malicious XML input [`CVE-2021-32796`](https://github.com/xmldom/xmldom/security/advisories/GHSA-5fg8-2547-mr8q)
75
- - Implement `Document.getElementsByClassName` as specified [`#213`](https://github.com/xmldom/xmldom/pull/213), thank you [@ChALkeR](https://github.com/ChALkeR)
91
+ - Implement `Document.getElementsByClassName` as specified [`#213`](https://github.com/xmldom/xmldom/pull/213), thank you, [@ChALkeR](https://github.com/ChALkeR)
76
92
  - Inherit namespace prefix from parent when required [`#268`](https://github.com/xmldom/xmldom/pull/268)
77
93
  - Handle whitespace in closing tags [`#267`](https://github.com/xmldom/xmldom/pull/267)
78
94
  - Update `DOMImplementation` according to recent specs [`#210`](https://github.com/xmldom/xmldom/pull/210)
@@ -80,7 +96,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
80
96
  - No longer serializes any namespaces with an empty URI [`#244`](https://github.com/xmldom/xmldom/pull/244)
81
97
  (related to [`#168`](https://github.com/xmldom/xmldom/pull/168) released in 0.6.0)
82
98
  BREAKING CHANGE: Only if you rely on ["unsetting" a namespace prefix](https://github.com/xmldom/xmldom/pull/168#issuecomment-886984994) by setting it to an empty string
83
- - Set `localName` as part of `Document.createElement` [`#229`](https://github.com/xmldom/xmldom/pull/229), thank you [@rrthomas](https://github.com/rrthomas)
99
+ - Set `localName` as part of `Document.createElement` [`#229`](https://github.com/xmldom/xmldom/pull/229), thank you, [@rrthomas](https://github.com/rrthomas)
84
100
 
85
101
  ### CI
86
102
 
@@ -99,7 +115,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
99
115
 
100
116
  - Stop serializing empty namespace values like `xmlns:ds=""` [`#168`](https://github.com/xmldom/xmldom/pull/168)
101
117
  BREAKING CHANGE: If your code expected empty namespaces attributes to be serialized.
102
- Thank you [@pdecat](https://github.com/pdecat) and [@FranckDepoortere](https://github.com/FranckDepoortere)
118
+ Thank you, [@pdecat](https://github.com/pdecat) and [@FranckDepoortere](https://github.com/FranckDepoortere)
103
119
  - Escape `<` to `&lt;` when serializing attribute values [`#198`](https://github.com/xmldom/xmldom/issues/198) / [`#199`](https://github.com/xmldom/xmldom/pull/199)
104
120
 
105
121
  ## 0.5.0
package/lib/dom.js CHANGED
@@ -62,7 +62,9 @@ function arrayIncludes (list) {
62
62
 
63
63
  function copy(src,dest){
64
64
  for(var p in src){
65
- dest[p] = src[p];
65
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
66
+ dest[p] = src[p];
67
+ }
66
68
  }
67
69
  }
68
70
 
@@ -488,6 +490,20 @@ Node.prototype = {
488
490
  hasAttributes:function(){
489
491
  return this.attributes.length>0;
490
492
  },
493
+ /**
494
+ * Look up the prefix associated to the given namespace URI, starting from this node.
495
+ * **The default namespace declarations are ignored by this method.**
496
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
497
+ *
498
+ * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
499
+ *
500
+ * @param {string | null} namespaceURI
501
+ * @returns {string | null}
502
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
503
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
504
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
505
+ * @see https://github.com/xmldom/xmldom/issues/322
506
+ */
491
507
  lookupPrefix:function(namespaceURI){
492
508
  var el = this;
493
509
  while(el){
@@ -495,9 +511,9 @@ Node.prototype = {
495
511
  //console.dir(map)
496
512
  if(map){
497
513
  for(var n in map){
498
- if(map[n] == namespaceURI){
499
- return n;
500
- }
514
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
515
+ return n;
516
+ }
501
517
  }
502
518
  }
503
519
  el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
@@ -512,7 +528,9 @@ Node.prototype = {
512
528
  //console.dir(map)
513
529
  if(map){
514
530
  if(prefix in map){
515
- return map[prefix] ;
531
+ if(Object.prototype.hasOwnProperty.call(map, prefix)){
532
+ return map[prefix] ;
533
+ }
516
534
  }
517
535
  }
518
536
  el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
@@ -1175,12 +1193,23 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
1175
1193
  var prefixedNodeName = nodeName
1176
1194
  if (!isHTML && !node.prefix && node.namespaceURI) {
1177
1195
  var defaultNS
1196
+ // lookup current default ns from `xmlns` attribute
1178
1197
  for (var ai = 0; ai < attrs.length; ai++) {
1179
1198
  if (attrs.item(ai).name === 'xmlns') {
1180
1199
  defaultNS = attrs.item(ai).value
1181
1200
  break
1182
1201
  }
1183
1202
  }
1203
+ if (!defaultNS) {
1204
+ // lookup current default ns in visibleNamespaces
1205
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1206
+ var namespace = visibleNamespaces[nsi]
1207
+ if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
1208
+ defaultNS = namespace.namespace
1209
+ break
1210
+ }
1211
+ }
1212
+ }
1184
1213
  if (defaultNS !== node.namespaceURI) {
1185
1214
  for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1186
1215
  var namespace = visibleNamespaces[nsi]
@@ -1365,11 +1394,13 @@ function importNode(doc,node,deep){
1365
1394
  // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
1366
1395
  function cloneNode(doc,node,deep){
1367
1396
  var node2 = new node.constructor();
1368
- for(var n in node){
1369
- var v = node[n];
1370
- if(typeof v != 'object' ){
1371
- if(v != node2[n]){
1372
- node2[n] = v;
1397
+ for (var n in node) {
1398
+ if (Object.prototype.hasOwnProperty.call(node, n)) {
1399
+ var v = node[n];
1400
+ if (typeof v != "object") {
1401
+ if (v != node2[n]) {
1402
+ node2[n] = v;
1403
+ }
1373
1404
  }
1374
1405
  }
1375
1406
  }
package/lib/sax.js CHANGED
@@ -135,8 +135,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
135
135
  if(endIgnoreCaseMach){
136
136
  domBuilder.endElement(config.uri,config.localName,tagName);
137
137
  if(localNSMap){
138
- for(var prefix in localNSMap){
139
- domBuilder.endPrefixMapping(prefix) ;
138
+ for(var prefix in localNSMap) {
139
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
140
+ domBuilder.endPrefixMapping(prefix);
141
+ }
140
142
  }
141
143
  }
142
144
  if(!endMatch){
@@ -472,8 +474,10 @@ function appendElement(el,domBuilder,currentNSMap){
472
474
  if(el.closed){
473
475
  domBuilder.endElement(ns,localName,tagName);
474
476
  if(localNSMap){
475
- for(prefix in localNSMap){
476
- domBuilder.endPrefixMapping(prefix)
477
+ for (prefix in localNSMap) {
478
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
479
+ domBuilder.endPrefixMapping(prefix);
480
+ }
477
481
  }
478
482
  }
479
483
  }else{
@@ -519,9 +523,15 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
519
523
  return pos<elStartEnd;
520
524
  //}
521
525
  }
522
- function _copy(source,target){
523
- for(var n in source){target[n] = source[n]}
526
+
527
+ function _copy (source, target) {
528
+ for (var n in source) {
529
+ if (Object.prototype.hasOwnProperty.call(source, n)) {
530
+ target[n] = source[n];
531
+ }
532
+ }
524
533
  }
534
+
525
535
  function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
526
536
  var next= source.charAt(start+2)
527
537
  switch(next){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmldom/xmldom",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
5
5
  "keywords": [
6
6
  "w3c",