Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/etl/src/Flow/ETL/Row/Entry/HTMLEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
?Metadata $metadata = null,
) {
if (\is_string($value)) {
$this->value = HTMLDocument::createFromString($value);
$this->value = HTMLDocument::createFromString($value, \LIBXML_NOERROR);
} else {
$this->value = $value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,36 @@ public function test_renames_entry() : void
self::assertEquals($entry->type(), $newEntry->type());
}

public function test_with_non_fully_valid_html_string() : void
{
$invalidHtml = <<<'HTML'
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div>foo</div>
<div><p><span>bar</span></span></p></div>
</body>
</html>
HTML;

$validHtml = <<<'HTML'
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<div>foo</div>
<div><p><span>bar</span></p></div>
</body>
</html>
HTML;

$entry = html_entry('html', $invalidHtml);

self::assertHtml($invalidHtml, $entry->toString(), false);
self::assertHtml($validHtml, $entry->toString(), true);
}

public function test_with_value() : void
{
$entry = html_entry('html', '<!DOCTYPE html><html lang="en"><head></head><body><div>foobar</div></body></html>');
Expand All @@ -178,4 +208,16 @@ public function test_with_value() : void
self::assertNotEquals($entry->toString(), $newEntry->toString());
self::assertEquals($html, $newEntry->value());
}

private function assertHtml(string $expected, string $html, bool $equals) : void
{
$expected = \preg_replace('/\s*/', '', $expected);
$html = \preg_replace('/\s*/', '', $html);

if ($equals) {
self::assertEquals($expected, $html);
} else {
self::assertNotEquals($expected, $html);
}
}
}
2 changes: 1 addition & 1 deletion src/lib/types/src/Flow/Types/Type/Logical/HTMLType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function cast(mixed $value) : HTMLDocument

/* @phpstan-ignore-next-line */
if (\is_string($value)) {
return HTMLDocument::createFromString($value);
return HTMLDocument::createFromString($value, \LIBXML_NOERROR);
}

return $value;
Expand Down
Loading