Skip to content

Commit 4322faa

Browse files
committed
fix: encode double-quot in URL
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 8fe2b4a commit 4322faa

13 files changed

+13
-12
lines changed

cyclonedx/model/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ class XsUri(serializable.helpers.BaseHelper):
689689

690690
__SPEC_REPLACEMENTS = (
691691
(' ', '%20'),
692+
('"', '%22'),
692693
('[', '%5B'),
693694
(']', '%5D'),
694695
('<', '%3C'),

tests/_data/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ def get_bom_for_issue_497_urls() -> Bom:
12131213
ExternalReference(
12141214
type=ExternalReferenceType.OTHER,
12151215
comment='control characters',
1216-
url=XsUri('https://acme.org/?foo=sp ace&bar[23]=42&lt=1<2&gt=3>2&cb={lol}')
1216+
url=XsUri('https://acme.org/?foo=sp ace&bar[23]=42&lt=1<2&gt=3>2&cb={lol}&dq=a"test"')
12171217
),
12181218
ExternalReference(
12191219
type=ExternalReferenceType.OTHER,

tests/_data/snapshots/get_bom_for_issue_497_urls-1.1.xml.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<comment>pre-encoded</comment>
1515
</reference>
1616
<reference type="other">
17-
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D</url>
17+
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D&amp;dq=a%22test%22</url>
1818
<comment>control characters</comment>
1919
</reference>
2020
</externalReferences>

tests/_data/snapshots/get_bom_for_issue_497_urls-1.2.json.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"comment": "control characters",
1818
"type": "other",
19-
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D"
19+
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D&dq=a%22test%22"
2020
}
2121
],
2222
"name": "dummy",

tests/_data/snapshots/get_bom_for_issue_497_urls-1.2.xml.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<comment>pre-encoded</comment>
1818
</reference>
1919
<reference type="other">
20-
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D</url>
20+
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D&amp;dq=a%22test%22</url>
2121
<comment>control characters</comment>
2222
</reference>
2323
</externalReferences>

tests/_data/snapshots/get_bom_for_issue_497_urls-1.3.json.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"comment": "control characters",
1818
"type": "other",
19-
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D"
19+
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D&dq=a%22test%22"
2020
}
2121
],
2222
"name": "dummy",

tests/_data/snapshots/get_bom_for_issue_497_urls-1.3.xml.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<comment>pre-encoded</comment>
1818
</reference>
1919
<reference type="other">
20-
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D</url>
20+
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D&amp;dq=a%22test%22</url>
2121
<comment>control characters</comment>
2222
</reference>
2323
</externalReferences>

tests/_data/snapshots/get_bom_for_issue_497_urls-1.4.json.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"comment": "control characters",
1818
"type": "other",
19-
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D"
19+
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D&dq=a%22test%22"
2020
}
2121
],
2222
"name": "dummy",

tests/_data/snapshots/get_bom_for_issue_497_urls-1.4.xml.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<comment>pre-encoded</comment>
1717
</reference>
1818
<reference type="other">
19-
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D</url>
19+
<url>https://acme.org/?foo=sp%20ace&amp;bar%5B23%5D=42&amp;lt=1%3C2&amp;gt=3%3E2&amp;cb=%7Blol%7D&amp;dq=a%22test%22</url>
2020
<comment>control characters</comment>
2121
</reference>
2222
</externalReferences>

tests/_data/snapshots/get_bom_for_issue_497_urls-1.5.json.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"comment": "control characters",
1818
"type": "other",
19-
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D"
19+
"url": "https://acme.org/?foo=sp%20ace&bar%5B23%5D=42&lt=1%3C2&gt=3%3E2&cb=%7Blol%7D&dq=a%22test%22"
2020
}
2121
],
2222
"name": "dummy",

0 commit comments

Comments
 (0)