News:

Support the VirtueMart project and become a member

Main Menu

Bug in htmlTools.class.php

Started by doorknob, November 01, 2009, 03:54:59 AM

Previous topic - Next topic

doorknob

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


doorknob

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




doorknob

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 where the thumbnails do not now cause xhtml compliance errors.
Regards
Phil

doorknob

Peter,
As of build 2296 this bug is still outstanding and my fix DOES WORK!!
Phil