diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 96b93e28945..e17cbff4a1a 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2512,7 +2512,7 @@ public function scaffoldFormFieldForHasOne( $list = DataList::create(static::class); $threshold = DBForeignKey::config()->get('dropdown_field_threshold'); $overThreshold = $list->count() > $threshold; - $field = SearchableDropdownField::create($fieldName, $fieldTitle, $list, $labelField) + $field = SearchableDropdownField::create($fieldName, $fieldTitle, $list, $ownerRecord->{$relationName . 'ID'}, $labelField) ->setIsLazyLoaded($overThreshold) ->setLazyLoadLimit($threshold); return $field; diff --git a/src/View/Parsers/HTMLValue.php b/src/View/Parsers/HTMLValue.php index ee44ec1421f..76b5ebc17af 100644 --- a/src/View/Parsers/HTMLValue.php +++ b/src/View/Parsers/HTMLValue.php @@ -32,7 +32,7 @@ public function __construct($fragment = null) */ public function setContent($content) { - $content = preg_replace('#]*>#si', '', $content); + $content = preg_replace('#]*>#si', '', $content); $html5 = new HTML5(['disable_html_ns' => true]); $document = $html5->loadHTML( '' . diff --git a/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php b/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php index 1a0196e6075..f17b1fe124e 100644 --- a/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php +++ b/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php @@ -182,7 +182,9 @@ public function testReadonlyField() $this->assertEquals( << - + + + @@ -199,7 +201,9 @@ public function testReadonlyField() $this->assertEquals( << - + + + diff --git a/tests/php/View/Parsers/HTMLValueTest.php b/tests/php/View/Parsers/HTMLValueTest.php index 7ce889dd738..52563498ace 100644 --- a/tests/php/View/Parsers/HTMLValueTest.php +++ b/tests/php/View/Parsers/HTMLValueTest.php @@ -160,4 +160,32 @@ public function testValidHTMLInNoscriptTags() $this->assertEquals($noscript, $value->getContent(), 'Child tags are left untouched in noscript tags.'); } } + + public function provideOnlyStripIntendedTags(): array + { + return [ + [ + 'input' => '

blahblah

', + 'expected' => '

blahblah

', + ], + [ + 'input' => '

blahblah

', + 'expected' => '

blahblah

', + ], + [ + 'input' => '

blahblah

', + 'expected' => '

blahblah

', + ], + ]; + } + + /** + * @dataProvider provideOnlyStripIntendedTags + */ + public function testOnlyStripIntendedTags(string $input, string $expected): void + { + $value = new HTMLValue(); + $value->setContent($input); + $this->assertEquals($expected, $value->getContent(), 'Invalid HTML can be parsed'); + } }