#214 problem testing empty textarea with tidy extension installed

open
nobody
None
5
2012-01-15
2012-01-15
Peter Meth
No

Version:
SimpleTest-1.1.alpha3
PHP 5.3.8 - WampServer
Windows 7 Ultimate 64-bit

I noticed a problem with $this->assertField('fieldname','');
The problem is that when the "tidy" php extension is installed, a different parser is used by SimpleTest. This parser seems to add an extra newline character to blank textarea values, which causes the assert to fail. The same assert passes when the "tidy" extension is not installed.
I believe this is a bug in tidy where tidy_parse_string(..) adds a \r to the end of the empty guard (eg. "___EMPTY___\r").

Steps to reproduce problem:
Install tidy extension in php
put an empty textarea field named fieldname on an html page, then write a simple test with
$this->assertField('fieldname','');
The test will fail if your version of tidy has the defect.

As a fix, I propose inserting the following before line 77 of tidy_parser.php:
// this should fix a bug with textareas where there is an extra \r on the end of the ___EMPTY___ guard.
$html = str_replace("___EMPTY___\r", "___EMPTY___", $html);

I don't think this should cause any problems even if the problem gets fixed in tidy.

Discussion