php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76683 tidy wraps even with wrap=0 (no wrapping)
Submitted: 2018-07-30 11:09 UTC Modified: 2018-10-15 15:07 UTC
From: jordi dot cardona at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Tidy (PECL)
PHP Version: 7.2.8 OS: Linux wc04.002info.com 4.17.7-10
Private report: No CVE-ID: None
 [2018-07-30 11:09 UTC] jordi dot cardona at gmail dot com
Description:
------------
Tidy wraps text elements even when 'wrap' = 0 has been stated in configuration.
As http://tidy.sourceforge.net/docs/quickref.html#wrap states that 0 value means no wrapping. This worked in past versions (< php 7.2.7) but at least from that version and up to php 7.2.8 the wrap is made. 

A posible worakaround is to state a great enough value (i.e: PHP_INT_MAX), but stating -1 works as well.

Test script:
---------------
<?php
ob_start();
?>
<html>a html document</html>
<?php
$html = ob_get_clean();

// Specify configuration
$config = array(
           'indent'         => true,
           'output-xhtml'   => true,
           'wrap'           => 0,
);

// Tidy
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();

// Output
echo $tidy;
?>



Expected result:
----------------
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title></title>
  </head>
  <body>
    a html document
  </body>
</html>


Actual result:
--------------
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>
    </title>
  </head>
  <body>
    a
    html
    document
  </body>
</html>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-30 14:23 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-07-30 14:23 UTC] cmb@php.net
I can't reproduce this with libtidy 5.4.0 (2017/03/01).  Which
libtidy version do you use (see PHP info)?
 [2018-07-31 11:15 UTC] jordi dot cardona at gmail dot com
-Status: Feedback +Status: Assigned
 [2018-07-31 11:15 UTC] jordi dot cardona at gmail dot com
My libtidy version is 5.6.0 (2017/11/25).
 [2018-07-31 12:15 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2018-07-31 12:15 UTC] cmb@php.net
Thanks!
 [2018-10-15 14:29 UTC] cmb@php.net
I have tried now with libtidy 5.6.0, and I get the expected
results.  The 5.6.0 docs still say that 0 should supress
wrapping[1].

[1] <http://api.html-tidy.org/tidy/quickref_5.6.0.html#wrap>
 [2018-10-15 15:07 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2018-10-15 15:07 UTC] cmb@php.net
> I have tried now with libtidy 5.6.0, […]

Sorry, that was actually libtidy 5.2.0.  I can reproduce the
reported behavior with libtidy 5.6.0 now.  It's caused by an
upstream bug[1], which has already been resolved (a new release is
pending, though).  Anyhow, this is not a PHP issue.

[1] <https://github.com/htacg/tidy-html5/issues/673>
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Oct 16 03:01:25 2018 UTC