Skip to content

Commit

Permalink
Merge pull request #16216 from craftcms/bugfix/16212-url-validation
Browse files Browse the repository at this point in the history
wrap League's Uri instantiation in try catch
  • Loading branch information
brandonkelly authored Nov 27, 2024
2 parents ce672fb + 604a7d1 commit 053c8e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed an error that could occur when duplicating an element with an Assets field that had a dynamic subpath. ([#16214](https://github.com/craftcms/cms/issues/16214))
- Fixed a bug where element slideouts had Save buttons even if the user didn’t have permission to save the element. ([#16205](https://github.com/craftcms/cms/pull/16205))
- Fixed a bug where pagination wasn’t working properly on the Entry Types index page when searching. ([#16204](https://github.com/craftcms/cms/issues/16204))
- Fixed an error that could occur when saving an element with an invalid Link field value. ([#16212](https://github.com/craftcms/cms/issues/16212))

## 5.5.3 - 2024-11-22

Expand Down
9 changes: 7 additions & 2 deletions src/fields/linktypes/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ protected function inputAttributes(): array

public function validateValue(string $value, ?string &$error = null): bool
{
// Leveraging Uri package to convert domains to punycode
return parent::validateValue(Uri::new($value), $error);
try {
// Leveraging Uri package to convert domains to punycode
$value = Uri::new($value);
return parent::validateValue($value, $error);
} catch (\Exception $e) {
return false;
}
}

protected function pattern(): string
Expand Down

0 comments on commit 053c8e1

Please sign in to comment.