Skip to content

Commit d559aa3

Browse files
authored
fix: encode quotation mark in URLs (#1155)
fixes #1154 --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent bdbe727 commit d559aa3

23 files changed

+177
-5
lines changed

HISTORY.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
<!-- add unreleased items here -->
88

9+
* Fixed
10+
* Encode quotation marks in URLs ([#1154] via [#1155])
911
* Build
1012
* Use _TypeScript_ `v5.6.2` now, was `v5.5.3` (via [#1130]. [#1144])
1113
* Use _webpack_ `v5.95.0` now, was `v5.93.0` (via [#1138], [#1147])
@@ -14,6 +16,8 @@ All notable changes to this project will be documented in this file.
1416
[#1138]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1138
1517
[#1144]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1144
1618
[#1147]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1147
19+
[#1154]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1154
20+
[#1155]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1155
1721

1822
## 6.11.0 -- 2024-07-15
1923

src/_helpers/uri.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
1919

2020
const _ESCAPES: Array<[RegExp, string]> = [
2121
[/ /g, '%20'],
22+
[/"/g, '%22'],
23+
[/'/g, '%27'],
2224
[/\[/g, '%5B'],
2325
[/]/g, '%5D'],
2426
[/</g, '%3C'],
2527
[/>/g, '%3E'],
2628
[/\{/g, '%7B'],
27-
[/}/g, '%7D']
29+
[/}/g, '%7D'],
2830
]
2931

3032
/**
@@ -34,10 +36,10 @@ const _ESCAPES: Array<[RegExp, string]> = [
3436
*
3537
* BEST EFFORT IMPLEMENTATION
3638
*
37-
* @see http://www.w3.org/TR/xmlschema-2/#anyURI
38-
* @see http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
39-
* @see https://datatracker.ietf.org/doc/html/rfc2396
40-
* @see https://datatracker.ietf.org/doc/html/rfc3987
39+
* @see {@link http://www.w3.org/TR/xmlschema-2/#anyURI}
40+
* @see {@link http://www.datypic.com/sc/xsd/t-xsd_anyURI.html}
41+
* @see {@link https://datatracker.ietf.org/doc/html/rfc2396}
42+
* @see {@link https://datatracker.ietf.org/doc/html/rfc3987}
4143
*/
4244
export function escapeUri<T extends (string | undefined)> (value: T): T {
4345
if (value === undefined) {

tests/_data/models.js

+1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ module.exports.createComplexStructure = function () {
284284
['encode anyUri: mailto', 'mailto:[email protected]'],
285285
['encode anyUri: relative path', '../foo/bar'],
286286
['encode anyUri: space', 'https://example.org/foo bar bazz%20again+again'],
287+
['encode anyUri: quotation', `https://example.org/this"test"isa'test'`],
287288
['encode anyUri: []', 'https://example.org/?bar[test]=baz[again]'],
288289
['encode anyUri: <>', 'https://example.org/#<test><again>'],
289290
['encode anyUri: {}', 'https://example.org/#{test}{again}'],

tests/_data/normalizeResults/json_sortedLists_spec1.2.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/json_sortedLists_spec1.3.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/json_sortedLists_spec1.4.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/json_sortedLists_spec1.5.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/json_sortedLists_spec1.6.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/xml_sortedLists_spec1.2.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/xml_sortedLists_spec1.3.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/xml_sortedLists_spec1.4.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/xml_sortedLists_spec1.5.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/normalizeResults/xml_sortedLists_spec1.6.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/json_complex_spec1.2.json.bin

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/json_complex_spec1.3.json.bin

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/json_complex_spec1.4.json.bin

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/json_complex_spec1.5.json.bin

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/json_complex_spec1.6.json.bin

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/xml_complex_spec1.2.xml.bin

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/xml_complex_spec1.3.xml.bin

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/xml_complex_spec1.4.xml.bin

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/xml_complex_spec1.5.xml.bin

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/_data/serializeResults/xml_complex_spec1.6.xml.bin

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)