Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: fivefilters\Readability\Nodes\NodeUtility::getNextNode(): … DOMProcessingInstruction returned #35

Open
blizzz opened this issue Jan 10, 2025 · 0 comments

Comments

@blizzz
Copy link

blizzz commented Jan 10, 2025

I know of web pages on one domain, where parsing results in a type error.

Following minimal test code shows the behaviour. The first page succeeds, the second on fails with the Type Error:

<?php

require __DIR__ . '/vendor/autoload.php';
use fivefilters\Readability\Readability;
use fivefilters\Readability\Configuration;

$readability = new Readability(new Configuration());

$content = file_get_contents('https://support.mozilla.org/en-US/kb/firefox-reader-view-clutter-free-web-pages');
$success = $readability->parse($content);

if ($success) {
	print("The mozilla.org page is fine!" . PHP_EOL);
}

$content = file_get_contents('https://weddingweiser.de/das-serratonin-erzeugt-gluecksgefuehle/');
$success = $readability->parse($content);

if ($success) {
	print("The weddingweiser.de page is fine!");
}

exit($success ? 0 : 1);

Output:

$ php repro.php 
The mozilla.org page is fine!
PHP Fatal error:  Uncaught TypeError: fivefilters\Readability\Nodes\NodeUtility::getNextNode(): Return value must be of type fivefilters\Readability\Nodes\DOM\DOMNode|fivefilters\Readability\Nodes\DOM\DOMComment|fivefilters\Readability\Nodes\DOM\DOMText|fivefilters\Readability\Nodes\DOM\DOMElement|fivefilters\Readability\Nodes\DOM\DOMDocument|null, fivefilters\Readability\Nodes\DOM\DOMProcessingInstruction returned in /home/blizzz/repos/readability-test/vendor/fivefilters/readability.php/src/Nodes/NodeUtility.php:135
Stack trace:
#0 /home/blizzz/repos/readability-test/vendor/fivefilters/readability.php/src/Readability.php(929): fivefilters\Readability\Nodes\NodeUtility::getNextNode(Object(fivefilters\Readability\Nodes\DOM\DOMElement))
#1 /home/blizzz/repos/readability-test/vendor/fivefilters/readability.php/src/Readability.php(177): fivefilters\Readability\Readability->getNodes(Object(fivefilters\Readability\Nodes\DOM\DOMElement))
#2 /home/blizzz/repos/readability-test/repro.php(17): fivefilters\Readability\Readability->parse('...')
#3 {main}
  thrown in /home/blizzz/repos/readability-test/vendor/fivefilters/readability.php/src/Nodes/NodeUtility.php on line 135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant