Author Topic: Bug in htmlTools.class.php  (Read 5209 times)

doorknob

  • Jr. Member
  • **
  • Posts: 151
Bug in htmlTools.class.php
« 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
Code: [Select]
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
Code: [Select]
$align = ($align) ? ' align="'.$align.'"' : '';
$height = ($height) ? ' height="'.$height.'"' : '';
$width = ($width) ? ' width="'.$width.'"' : '';
$title = ($title) ? ' title="'.$title.'"' : '';
$attributes = ($attributes) ? ' ' . $attributes : '';

Regards
Phil

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Bug in htmlTools.class.php
« Reply #1 on: November 02, 2009, 23:30:32 pm »
Thank you for bringing this bug to our attention however tried your solution didn't work.

doorknob

  • Jr. Member
  • **
  • Posts: 151
Re: Bug in htmlTools.class.php
« Reply #2 on: November 03, 2009, 00:20:12 am »
Peter,
Quote
tried 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

  • Jr. Member
  • **
  • Posts: 151
Re: Bug in htmlTools.class.php
« Reply #4 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 where the thumbnails do not now cause xhtml compliance errors.
Regards
Phil

doorknob

  • Jr. Member
  • **
  • Posts: 151
Re: Bug in htmlTools.class.php
« Reply #5 on: February 04, 2010, 18:01:33 pm »
Peter,
As of build 2296 this bug is still outstanding and my fix DOES WORK!!
Phil