Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: encode quotation mark in URLs #1155

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.

<!-- add unreleased items here -->

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

## 6.11.0 -- 2024-07-15

Expand Down
12 changes: 7 additions & 5 deletions src/_helpers/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ Copyright (c) OWASP Foundation. All Rights Reserved.

const _ESCAPES: Array<[RegExp, string]> = [
[/ /g, '%20'],
[/"/g, '%22'],
[/'/g, '%27'],
[/\[/g, '%5B'],
[/]/g, '%5D'],
[/</g, '%3C'],
[/>/g, '%3E'],
[/\{/g, '%7B'],
[/}/g, '%7D']
[/}/g, '%7D'],
]

/**
Expand All @@ -34,10 +36,10 @@ const _ESCAPES: Array<[RegExp, string]> = [
*
* BEST EFFORT IMPLEMENTATION
*
* @see http://www.w3.org/TR/xmlschema-2/#anyURI
* @see http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
* @see https://datatracker.ietf.org/doc/html/rfc2396
* @see https://datatracker.ietf.org/doc/html/rfc3987
* @see {@link http://www.w3.org/TR/xmlschema-2/#anyURI}
* @see {@link http://www.datypic.com/sc/xsd/t-xsd_anyURI.html}
* @see {@link https://datatracker.ietf.org/doc/html/rfc2396}
* @see {@link https://datatracker.ietf.org/doc/html/rfc3987}
*/
export function escapeUri<T extends (string | undefined)> (value: T): T {
if (value === undefined) {
Expand Down
1 change: 1 addition & 0 deletions tests/_data/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ module.exports.createComplexStructure = function () {
['encode anyUri: mailto', 'mailto:[email protected]'],
['encode anyUri: relative path', '../foo/bar'],
['encode anyUri: space', 'https://example.org/foo bar bazz%20again+again'],
['encode anyUri: quotation', `https://example.org/this"test"isa'test'`],
['encode anyUri: []', 'https://example.org/?bar[test]=baz[again]'],
['encode anyUri: <>', 'https://example.org/#<test><again>'],
['encode anyUri: {}', 'https://example.org/#{test}{again}'],
Expand Down
5 changes: 5 additions & 0 deletions tests/_data/normalizeResults/json_sortedLists_spec1.2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/normalizeResults/json_sortedLists_spec1.3.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/normalizeResults/json_sortedLists_spec1.4.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/normalizeResults/json_sortedLists_spec1.5.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/normalizeResults/json_sortedLists_spec1.6.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/_data/normalizeResults/xml_sortedLists_spec1.2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/_data/normalizeResults/xml_sortedLists_spec1.3.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/_data/normalizeResults/xml_sortedLists_spec1.4.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/_data/normalizeResults/xml_sortedLists_spec1.5.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/_data/normalizeResults/xml_sortedLists_spec1.6.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/serializeResults/json_complex_spec1.2.json.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/serializeResults/json_complex_spec1.3.json.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/serializeResults/json_complex_spec1.4.json.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/serializeResults/json_complex_spec1.5.json.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/_data/serializeResults/json_complex_spec1.6.json.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/_data/serializeResults/xml_complex_spec1.2.xml.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/_data/serializeResults/xml_complex_spec1.3.xml.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/_data/serializeResults/xml_complex_spec1.4.xml.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/_data/serializeResults/xml_complex_spec1.5.xml.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/_data/serializeResults/xml_complex_spec1.6.xml.bin

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading