php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53163 trim() don't say about warning with tidy_parse_string
Submitted: 2010-10-26 10:35 UTC Modified: 2010-10-26 10:46 UTC
From: borovoy dot anton at gmail dot com Assigned:
Status: Not a bug Package: Tidy (PECL)
PHP Version: 5.3.3 OS: Gentoo
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: borovoy dot anton at gmail dot com
New email:
PHP Version: OS:

 

 [2010-10-26 10:35 UTC] borovoy dot anton at gmail dot com
Description:
------------
<?php
class test { public $value = 'Hi'; }                                                                                          
$obj = new test();                                                                                                            
trim($obj);
?>
result: Warning: trim() expects parameter 1 to be string, object given

<?php
$content = file_get_contents('http://php.net');                                                                               
while ($i = 1) { trim(tidy_parse_string($content, $tidy_config, 'utf8')); }
?>
result: Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to 
allocate 104 bytes)
php: tidylib.c:168: tidyDocRelease: Assertion `doc->docIn == ((void *)0)' 
failed.

I think need warning and not eat all memory
thx


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-26 10:46 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2010-10-26 10:46 UTC] rasmus@php.net
You have your memory limit set really low and you are looping infinitely over a 
tidy_parse_string call against a 50k blob of html.
This has nothing to do with trim.  You are running out of memory doing all the 
tidy stuff long before trim() is even called.
 [2010-10-26 11:00 UTC] borovoy dot anton at gmail dot com
At first time it was: Fatal error: Allowed memory size of 1073741824 bytes 
exhausted (tried to allocate 3 bytes)

btw:
In http://php.net/manual/en/tidy.examples.basic.php we get:
<?php
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
echo $tidy;
?>
If before echo() we put:
var_dump(is_object($tidy));
var_dump(is_string($tidy));

result will be:
bool(true)
bool(false)

In php.net/manual/en/function.echo.php says echo wanna string, not object
And if use $tidy->value problem resolve.

What I don't understand?
thx
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 12:01:32 2025 UTC