Skip to content

Commit

Permalink
Fixed a bug where Redactor field would crash if attempting to save co…
Browse files Browse the repository at this point in the history
…ntent that had empty links.

Resolve #355
  • Loading branch information
andris-sevcenko committed Feb 1, 2022
1 parent 1fdc242 commit 3939c05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for Redactor for Craft CMS

## Unreleased

### Fixed
- Fixed a bug where Redactor field would crash if attempting to save content that had empty links. ([#355](https://github.com/craftcms/redactor/issues/355))

## 2.9.0 - 2022-01-31

### Added
Expand Down
6 changes: 5 additions & 1 deletion src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,11 @@ function($matches) {
$value = preg_replace_callback(
'/(href=|src=)([\'"])(http.*)?\2/',
function($matches) use ($sortArray, $siteUrlsById) {
$url = $matches[3];
$url = $matches[3] ?? null;

if (!$url) {
return '';
}

// Longest URL first
foreach ($sortArray as $siteId => $bogus) {
Expand Down

0 comments on commit 3939c05

Please sign in to comment.