php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75947 Tidy creates an undocumented property Tidy->value
Submitted: 2018-02-10 20:02 UTC Modified: 2018-02-28 23:15 UTC
From: tandre at themeetgroup dot com Assigned:
Status: Verified Package: Tidy (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tandre at themeetgroup dot com
New email:
PHP Version: OS:

 

 [2018-02-10 20:02 UTC] tandre at themeetgroup dot com
Description:
------------
The test script shows that $x->value is indeed being created after calling parseString.

This property seems like it is created in all versions from PHP 5.0 to 7.2 (haven't checked earlier versions)

https://github.com/php/php-src/blob/PHP-5.0/ext/tidy/tidy.c#L685-L690
https://github.com/php/php-src/blob/PHP-7.2.2/ext/tidy/tidy.c#L820-L827

However, Tidy->value is not mentioned in any of the following places:

- https://secure.php.net/manual/en/class.tidy.php#tidy.synopsis
- https://secure.php.net/manual/en/tidy.parsestring.php#refsect1-tidy.parsestring-examples does not mention that $tidy->value would be created.


Also, I'm wondering it it would make sense to deprecate attempts to access Tidy->value in PHP 7.3:

- It's undocumented, so not many applications would use it (hopefully)
- It's inefficient to generate HTML/XML strings which which won't be used
- Not sure if generating the string affects Tidy->errorBuffer.

I discovered this when investigating a bug in php's use of tidy-html5 5.6.0 (worked in 5.4.0): https://github.com/htacg/tidy-html5/issues/673#issuecomment-364683244 

- Feel free to file a new issue for that if it makes sense to? I wasn't sure.

Test script:
---------------
$x = new Tidy();
$x->parseString('<p>example</p>', ['show-body-only'=>true]);
printf("Value property:   %s\n", $x->value);  // $x->value exists after calling parseString/parseFile, but 
printf("cast to (string): %s\n", (string)$x);

Expected result:
----------------
I expect the existence of the property Tidy->value to be documented on php.net (Or to be deprecated in php 7.3 and removed in 8.0)

Actual result:
--------------
Tidy->value is not documented, but exists.
The above test script outputs the following:

Value property:   <p>example</p>

cast to (string): <p>example</p>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-28 23:15 UTC] cmb@php.net
-Summary: Tidy creates an undocumented property Tidy->value after calling parseString() +Summary: Tidy creates an undocumented property Tidy->value -Status: Open +Status: Verified
 [2018-02-28 23:15 UTC] cmb@php.net
> The test script shows that $x->value is indeed being created
> after calling parseString.

Actually, the `value` property is already created when the tidy
object is instantiated.  POC:

  <?php
  $x = new tidy;
  var_dump(
      property_exists('tidy', 'value'),
      property_exists($x, 'value)
  );

gives

  bool(false)
  bool(true)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 15:01:26 2019 UTC