Skip to content

Commit 45d904e

Browse files
chore(deps-dev): bump the eslint group with 1 update (#1000)
* chore(deps-dev): bump the eslint group with 1 update Bumps the eslint group with 1 update: [eslint-config-standard-with-typescript](https://github.com/standard/eslint-config-standard-with-typescript). - [Release notes](https://github.com/standard/eslint-config-standard-with-typescript/releases) - [Changelog](https://github.com/standard/eslint-config-standard-with-typescript/blob/master/CHANGELOG.md) - [Commits](mightyiam/eslint-config-love@v40.0.0...v42.0.0) --- updated-dependencies: - dependency-name: eslint-config-standard-with-typescript dependency-type: direct:development update-type: version-update:semver-major dependency-group: eslint ... Signed-off-by: dependabot[bot] <[email protected]> * fix: Possible bug in XML serialization of undefined children Signed-off-by: Jan Kowalleck <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Jan Kowalleck <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jan Kowalleck <[email protected]>
1 parent 233429f commit 45d904e

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
## unreleased
66

7+
* Fixed
8+
* Possible bug in XML serialization of undefined children (via [#1000])
79
* Build
810
* Use _TypeScript_ `v5.3.3` now, was `v5.3.2` (via [#999])
911

1012
[#999]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/999
13+
[#1000]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1000
1114

1215
## 6.1.2 -- 2023-12-02
1316

libs/universal-node-xml/stringifiers/xmlbuilder2.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ module.exports = typeof create === 'function'
3838
/* eslint-enable jsdoc/valid-types */
3939

4040
/**
41-
* @param {Element} element
41+
* @param {Element} rootElement
4242
* @param {string|number|undefined} [space]
4343
* @return {string}
4444
*/
45-
function stringify (element, { space } = {}) {
45+
function stringify (rootElement, { space } = {}) {
4646
const indent = makeIndent(space)
4747
const doc = create({ encoding: 'UTF-8' })
48-
addEle(doc, element)
48+
addEle(doc, rootElement)
4949
return doc.end({
5050
format: 'xml',
5151
newline: '\n',
@@ -63,9 +63,11 @@ function addEle (parent, element, parentNS = null) {
6363
if (element.type !== 'element') { return }
6464
const ns = getNS(element) ?? parentNS
6565
const ele = parent.ele(ns, element.name, element.attributes)
66-
if (typeof element.children === 'string' || typeof element.children === 'number') {
66+
if (element.children === undefined) {
67+
/* pass */
68+
} else if (typeof element.children === 'string' || typeof element.children === 'number') {
6769
ele.txt(element.children.toString())
68-
} else if (Array.isArray(element.children)) {
70+
} else {
6971
for (const child of element.children) {
7072
addEle(ele, child, ns)
7173
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"deepmerge": "^4.2.2",
8585
"eslint": "8.55.0",
8686
"eslint-config-standard": "17.1.0",
87-
"eslint-config-standard-with-typescript": "40.0.0",
87+
"eslint-config-standard-with-typescript": "42.0.0",
8888
"eslint-plugin-header": "3.1.1",
8989
"eslint-plugin-jsdoc": "46.9.0",
9090
"eslint-plugin-simple-import-sort": "10.0.0",

src/serialize/xmlSerializer.web.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export class XmlSerializer extends XmlBaseSerializer {
3636
}
3737

3838
#buildXmlDocument (
39-
normalizedBom: SimpleXml.Element
39+
rootElement: SimpleXml.Element
4040
): XMLDocument {
4141
const namespace = null
4242
const doc = document.implementation.createDocument(namespace, null)
43-
doc.appendChild(this.#buildElement(normalizedBom, doc, namespace))
43+
doc.appendChild(this.#buildElement(rootElement, doc, namespace))
4444
return doc
4545
}
4646

@@ -58,7 +58,7 @@ export class XmlSerializer extends XmlBaseSerializer {
5858
this.#setAttributes(node, element.attributes)
5959
}
6060
if (isNotUndefined(element.children)) {
61-
this.#setChildren(node, element.children, ns)
61+
this.#addChildren(node, element.children, ns)
6262
}
6363
return node
6464
}
@@ -72,14 +72,18 @@ export class XmlSerializer extends XmlBaseSerializer {
7272
}
7373
}
7474

75-
#setChildren (node: Element, children: SimpleXml.ElementChildren, parentNS: string | null = null): void {
75+
#addChildren (node: Element, children: SimpleXml.ElementChildren, parentNS: string | null = null): void {
76+
if (children === undefined) {
77+
return
78+
}
79+
7680
if (typeof children === 'string' || typeof children === 'number') {
7781
node.textContent = children.toString()
7882
return
7983
}
8084

8185
const doc = node.ownerDocument
82-
for (const child of (children as Iterable<SimpleXml.Comment | SimpleXml.Element>)) {
86+
for (const child of children) {
8387
if (child.type === 'element') {
8488
node.appendChild(this.#buildElement(child, doc, parentNS))
8589
}

src/spdx.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const spdxLowerToActual: Readonly<Record<string, SpdxId>> = Object.freeze(Object
3838
))
3939

4040
export function isSupportedSpdxId (value: SpdxId | any): value is SpdxId {
41+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
4142
return spdxIds.has(value)
4243
}
4344

src/spec/_protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,17 @@ export class _Spec implements _SpecProtocol {
109109
}
110110

111111
supportsFormat (f: Format | any): boolean {
112+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
112113
return this.#formats.has(f)
113114
}
114115

115116
supportsComponentType (ct: ComponentType | any): boolean {
117+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
116118
return this.#componentTypes.has(ct)
117119
}
118120

119121
supportsHashAlgorithm (ha: HashAlgorithm | any): boolean {
122+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
120123
return this.#hashAlgorithms.has(ha)
121124
}
122125

@@ -126,6 +129,7 @@ export class _Spec implements _SpecProtocol {
126129
}
127130

128131
supportsExternalReferenceType (ert: ExternalReferenceType | any): boolean {
132+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
129133
return this.#externalReferenceTypes.has(ert)
130134
}
131135

@@ -151,6 +155,7 @@ export class _Spec implements _SpecProtocol {
151155
}
152156

153157
supportsVulnerabilityRatingMethod (rm: Vulnerability.RatingMethod | any): boolean {
158+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
154159
return this.#vulnerabilityRatingMethods.has(rm)
155160
}
156161

0 commit comments

Comments
 (0)