VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Virtuemart 1.1 Development (Archiv) => Quality & Testing VirtueMart 1.1.x => Topic started by: doorknob on November 01, 2009, 03:54:59 AM

Title: Bug in htmlTools.class.php
Post by: doorknob on November 01, 2009, 03:54:59 AM
The function imageTag checks whether each of a number of values is not empty and, if so, creates an appropriate element in the tag. Unfortunately, a value of zero is considered empty and as a result, spurious numeric zeros can be included in the tag making it invalid. ps_product calls this function with default values for height and width of zero. This causes corruption of the image tags.

I fixed this by changing lines 587-591 from
if( $align ) { $align = ' align="'.$align.'"'; }
if( $height ) { $height = ' height="'.$height.'"'; }
if( $width ) { $width = ' width="'.$width.'"'; }
if( $title ) { $title = ' title="'.$title.'"'; }
if( $attributes ) { $attributes = ' ' . $attributes; }

to
$align = ($align) ? ' align="'.$align.'"' : '';
$height = ($height) ? ' height="'.$height.'"' : '';
$width = ($width) ? ' width="'.$width.'"' : '';
$title = ($title) ? ' title="'.$title.'"' : '';
$attributes = ($attributes) ? ' ' . $attributes : '';


Regards
Phil
Title: Re: Bug in htmlTools.class.php
Post by: aravot on November 02, 2009, 23:30:32 PM
Thank you for bringing this bug to our attention however tried your solution didn't work.
Title: Re: Bug in htmlTools.class.php
Post by: doorknob on November 03, 2009, 00:20:12 AM
Peter,
Quotetried your solution didn't work.

What was the problem?

The original code returns a valid element for values other than zero and ignores empty strings but leaves zeros unchanged, causing a problem.

The changed version of the code also returns a valid element for values other than zero but returns an empty string for zero


Title: Re: Bug in htmlTools.class.php
Post by: aravot on November 03, 2009, 01:36:44 AM
With and without your changes I get following errors.
http://dev.virtuemart.net/cb/issue/2762
Title: Re: Bug in htmlTools.class.php
Post by: doorknob on November 03, 2009, 03:20:55 AM
Peter,
I think we may be at cross purposes. The function ps_product->image_tag() sets default values of zero for the height and width of the image. If these defaults are not overridden (which is always the case if the 'resize' option is not set) then those zero values are passed to vmCommonHTML::imageTag(). When that happens, the tag gets corrupted, causing a compliance error and my suggested change prevents that by converting the zeros into empty strings. As you can see, at http://www.eyeforabargain.co.uk/Bargains-Bazaar/Page-1-20.html (http://www.eyeforabargain.co.uk/Bargains-Bazaar/Page-1-20.html) where the thumbnails do not now cause xhtml compliance errors.
Regards
Phil
Title: Re: Bug in htmlTools.class.php
Post by: doorknob on February 04, 2010, 18:01:33 PM
Peter,
As of build 2296 this bug is still outstanding and my fix DOES WORK!!
Phil