Skip to content

Commit

Permalink
remove url validation of `CycloneDX\Core\Models\License\AbstractDisju…
Browse files Browse the repository at this point in the history
…nctiveLicense::setUrl()`

fixes #18

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Nov 20, 2021
1 parent b1ca509 commit 9481e41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file.

## unreleased

* Fixed
* `CycloneDX\Core\Models\License\AbstractDisjunctiveLicense::setUrl()` no longer restricts the argument to be a valid URL.
Per schema definition `licenseType.url` should be a URI, not a URL.
* Changed
* `CycloneDX\Core\Models\License\AbstractDisjunctiveLicense::setUrl()` no longer throws `InvalidArgumentException`
if the argument is not a URL.

## 1.0.2 - 2021-10-30

* Fixed
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"require": {
"php": "^7.3 || ^8.0",
"ext-dom": "*",
"ext-filter": "*",
"ext-json": "*",
"ext-libxml": "*",
"package-url/packageurl-php": "^1.0",
Expand Down
7 changes: 0 additions & 7 deletions src/Core/Models/License/AbstractDisjunctiveLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

namespace CycloneDX\Core\Models\License;

use InvalidArgumentException;

/**
* @author jkowalleck
*
Expand All @@ -46,15 +44,10 @@ public function getUrl(): ?string
}

/**
* @throws InvalidArgumentException if value is an invalid URL
*
* @return $this
*/
public function setUrl(?string $url): self
{
if (null !== $url && false === filter_var($url, \FILTER_VALIDATE_URL)) {
throw new InvalidArgumentException("Invalid URL: $url");
}
$this->url = $url;

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
namespace CycloneDX\Tests\Core\Models\License;

use CycloneDX\Core\Models\License\AbstractDisjunctiveLicense;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -45,11 +44,10 @@ public function testSetAndGetUrl(): AbstractDisjunctiveLicense
/**
* @depends testSetAndGetUrl
*/
public function testSetUrlThrows(AbstractDisjunctiveLicense $license): void
public function testSetUrlToSomeUri(AbstractDisjunctiveLicense $license): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/invalid URL/i');
$license->setUrl('foo');
$license->setUrl('../foo.txt');
self::assertSame('../foo.txt', $license->getUrl());
}

/**
Expand Down

0 comments on commit 9481e41

Please sign in to comment.