diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 96b93e289..e17cbff4a 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2512,7 +2512,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $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 ee44ec142..76b5ebc17 100644 --- a/src/View/Parsers/HTMLValue.php +++ b/src/View/Parsers/HTMLValue.php @@ -32,7 +32,7 @@ class HTMLValue extends ViewableData */ 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 1a0196e60..f17b1fe12 100644 --- a/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php +++ b/tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php @@ -182,7 +182,9 @@ class HTMLEditorFieldTest extends FunctionalTest $this->assertEquals( << - + + + @@ -199,7 +201,9 @@ EOS $this->assertEquals( << - + + + diff --git a/tests/php/View/Parsers/HTMLValueTest.php b/tests/php/View/Parsers/HTMLValueTest.php index 7ce889dd7..52563498a 100644 --- a/tests/php/View/Parsers/HTMLValueTest.php +++ b/tests/php/View/Parsers/HTMLValueTest.php @@ -160,4 +160,32 @@ class HTMLValueTest extends SapphireTest $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'); + } }