commit 765bb58fc7 Author: Karoly Negyesi Date: Wed Dec 11 21:57:53 2019 -0800 WEB-7020 validate link uris diff --git a/docroot/modules/custom/sd8/sd8.module b/docroot/modules/custom/sd8/sd8.module index 080b01389c..a5c49d692c 100644 --- a/docroot/modules/custom/sd8/sd8.module +++ b/docroot/modules/custom/sd8/sd8.module @@ -445,3 +445,10 @@ function sd8_entity_access(EntityInterface $entity, $operation, AccountInterface } return $access; } + +/** + * Implements hook_field_info_alter(). + */ +function sd8_field_info_alter(&$info) { + $info['link']['constraints']['LinkUriValid'] = []; +} diff --git a/docroot/modules/custom/sd8/src/Plugin/Validation/Constraint/LinkUriValidConstraint.php b/docroot/modules/custom/sd8/src/Plugin/Validation/Constraint/LinkUriValidConstraint.php new file mode 100644 index 0000000000..b28d094465 --- /dev/null +++ b/docroot/modules/custom/sd8/src/Plugin/Validation/Constraint/LinkUriValidConstraint.php @@ -0,0 +1,19 @@ +getUrl(); + parent::validate($url->setAbsolute()->toString(), $constraint); + } + catch (\Exception $e) { + // This is not our job, it can be invalid internal path and more. + } + } + } + +}