Skip to content

Commit 240f193

Browse files
committed
#1557 added test for handling encoded ':'s
1 parent 04c0425 commit 240f193

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/unit-tests/cve/validatePurlTest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ const MultipleRecordsOneInvalid = [
104104
}
105105
]
106106

107+
const PurlEncodedColonRecord = [
108+
{
109+
packageURL: 'pkg:pypi/django#%3A'
110+
}
111+
]
112+
107113
const RecordNoPurl = [
108114
{
109115
test: 'testing String'
@@ -164,5 +170,9 @@ describe('Testing validatePURL middleware', () => {
164170
it('Should fail to validate when a version is passed in the qualifier component ', () => {
165171
expect(() => purlValidateHelper(RecordQualifierVersionPurl)).to.throw('PURL versions are currently not supported by the CVE schema: ' + RecordQualifierVersionPurl[0].packageURL)
166172
})
173+
174+
it('Should fail to validate when a PURL contain an encoded colon ', () => {
175+
expect(() => purlValidateHelper(PurlEncodedColonRecord)).to.throw('Percent-encoded colons are not allowed in a PURL: ' + PurlEncodedColonRecord[0].packageURL)
176+
})
167177
})
168178
})

0 commit comments

Comments
 (0)