cvs: pear /PHPUnit package.xml /PHPUnit/PHPUnit/GUI HTML.php

From: Date: Sat, 17 Apr 2004 06:01:32 +0000
Subject: cvs: pear /PHPUnit package.xml /PHPUnit/PHPUnit/GUI HTML.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18333@lists.php.net to get a copy of this message
sebastian Sat Apr 17 02:01:32 2004 EDT Modified files: /pear/PHPUnit package.xml /pear/PHPUnit/PHPUnit/GUI HTML.php Log: Fix a bug that let the HTML GUI fail for expected and/or actual results with newline characters. (Patch by Thiemo Maettig <thiemo.maettig@gmx.de>) http://cvs.php.net/diff.php/pear/PHPUnit/package.xml?r1=1.67&r2=1.68&ty=u Index: pear/PHPUnit/package.xml diff -u pear/PHPUnit/package.xml:1.67 pear/PHPUnit/package.xml:1.68 --- pear/PHPUnit/package.xml:1.67 Wed Apr 14 11:37:04 2004 +++ pear/PHPUnit/package.xml Sat Apr 17 02:01:32 2004 @@ -19,11 +19,16 @@ </maintainers> <license>PHP License</license> <release> - <version>1.0.1-dev</version> - <state>devel</state> - <date>2004-MM-DD</date> + <version>1.0.1</version> + <state>stable</state> + <date>2004-04-17</date> <notes> <![CDATA[ +* Fixed a bug that let the HTML GUI fail for expected and/or actual + results with newline characters. + + (Patch by Thiemo Maettig <thiemo.maettig@gmx.de>) + * Fixed bug #1169. ]]> </notes> http://cvs.php.net/diff.php/pear/PHPUnit/PHPUnit/GUI/HTML.php?r1=1.9&r2=1.10&ty=u Index: pear/PHPUnit/PHPUnit/GUI/HTML.php diff -u pear/PHPUnit/PHPUnit/GUI/HTML.php:1.9 pear/PHPUnit/PHPUnit/GUI/HTML.php:1.10 --- pear/PHPUnit/PHPUnit/GUI/HTML.php:1.9 Wed Apr 14 11:37:05 2004 +++ pear/PHPUnit/PHPUnit/GUI/HTML.php Sat Apr 17 02:01:32 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: HTML.php,v 1.9 2004/04/14 15:37:05 sebastian Exp $ +// $Id: HTML.php,v 1.10 2004/04/17 06:01:32 sebastian Exp $ // /** @@ -154,23 +154,31 @@ // if so we try to unserialize it // this piece of the regular expression is for detecting a serialized // type like 'a:3:' for an array with three element or an object i.e. 'O:12:"class":3' - $serializePrefix = '(\\w:\\d+:|O:\\d+:"[a-z_]+":\\d+:)?'; - if (preg_match('/expected\s+'.$serializePrefix.'{.*}, actual\s+'.$serializePrefix.'{.*}/i',$exception)) { + $serialized = '(\w:\d+:(?:"[^"]+":\d+:)?\{.*\})'; + // Spaces might make a diff, so we shall show them properly (since a + // user agent ignores them). + if (preg_match('/^(.*)expected ' . $serialized . ', actual ' . + $serialized . '$/sU', $exception, $matches)) { ob_start(); - print_r(unserialize(preg_replace('/expected\s+(.*), actual.*/','$1',$exception))); - $ret['expected'] = '<pre>'.ob_get_contents().'</pre>'; - ob_clean(); - print_r(unserialize(preg_replace('/expected\s.*, actual (.*)/','$1',$exception))); - $ret['actual'] = '<pre>'.ob_get_contents().'</pre>'; + print_r(unserialize($matches[2])); + $ret['expected'] = htmlspecialchars($matches[1]) . "<pre>" . + htmlspecialchars(rtrim(ob_get_contents())) . "</pre>"; + // Improved compatibility, ob_clean() would be PHP >= 4.2.0 only. ob_end_clean(); + ob_start(); + print_r(unserialize($matches[3])); + $ret['actual'] = htmlspecialchars($matches[1]) . "<pre>" . + htmlspecialchars(rtrim(ob_get_contents())) . "</pre>"; + ob_end_clean(); + } elseif (preg_match('/^(.*)expected (.*), actual (.*)$/sU', $exception, + $matches)) { + $ret['expected'] = nl2br(str_replace(" ", "&nbsp;", + htmlspecialchars($matches[1] . $matches[2]))); + $ret['actual'] = nl2br(str_replace(" ", "&nbsp;", + htmlspecialchars($matches[1] . $matches[3]))); } else { - // spaces might make a diff, so we shall show them properly (since a user agent ignores them) - if (preg_match('/expected\s.*, actual.*/',$exception)) { - $ret['expected'] = preg_replace('/expected\s(.*), actual.*/','$1',$exception); - $ret['actual'] = preg_replace('/expected\s.*, actual (.*)/','$1',$exception); - } else { - $ret['message'] = str_replace(' ','&nbsp;',$exception); - } + $ret['message'] = nl2br(str_replace(" ", "&nbsp;", + htmlspecialchars($exception))); } return $ret;

« previous php.pear.cvs (#18333) next »