Skip to content

Commit ae059fc

Browse files
committed
tidy: use tidy_repair_string instead of tidy_parse_string+tidy_clean_repair
A change released in tidy 5.6.0 breaks php-tidy when using tidy_parse_string+tidy_clean_repair and wrap=0, incorrectly wrapping every single word. Also it seems that $tidy->value should not be used to retrieve the repaired html as far as it is undocumented and for internal use. We replace the call with tidy_repair_string which directly returns the repaired string. Relates to htacg/tidy-html5#673 Relates to https://bugs.php.net/bug.php?id=75947 Tests pass. Signed-off-by: Kevin Decherf <[email protected]>
1 parent bbe9021 commit ae059fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Readability.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ private function loadHtml()
274274
if ($this->useTidy) {
275275
$this->logger->debug('Tidying document');
276276

277-
$tidy = tidy_parse_string($this->html, $this->tidy_config, 'UTF8');
278-
if (tidy_clean_repair($tidy)) {
277+
$tidy = tidy_repair_string($this->html, $this->tidy_config, 'UTF8');
278+
if (false !== $tidy && $this->html !== $tidy) {
279279
$this->tidied = true;
280-
$this->html = $tidy->value;
280+
$this->html = $tidy;
281281
$this->html = preg_replace('/[\r\n]+/is', "\n", $this->html);
282282
}
283283
unset($tidy);

0 commit comments

Comments
 (0)