The HTML produced by the brilliant_gallery module fails XHTML 1.0 Strict validation done at http://validator.w3.org/ because some of the URLs it generates have naked &s which are required to be escaped as & by the URI standard.

Most seem to be escaped but there are two lines that need to be changed. Once I did that the generated HTML passed validation for me. The lines are:

brilliant_gallery.module line 820:

$result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgwbig .'&imgh='. $imghbig .'"';

change to:

$result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&amp;imgw='. $imgwbig .'&amp;imgh='. $imghbig .'"';

brilliant_gallery.module line 866:
$result .= '<img style="border: 0; margin:0px; padding:0px;" alt="" src="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgw .'&imgh='. $imgh . '&imgcrop='. $imgcrop.'" />';

change to:

$result .= '<img style="border: 0; margin:0px; padding:0px;" alt="" src="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&amp;imgw='. $imgw .'&amp;imgh='. $imgh . '&amp;imgcrop='. $imgcrop.'" />';

As an alternative approach, I noticed that in the Lightbox2 module it just creates the URLs as plain strings with no special characters escaped. Once the URL string has been created it is cleaned by using check_plain() which presumably does all the necessary escaping. The advantage of this is that there may be more than &s that need escaping and the Drupal core check_plain() may take care of it. This may also avoid needing to use base64_encode() as the check_plain may take care of that as well.

I also came across another core function drupal_urlencode() that may be appropriate on the final complete URL. It is explicitly intended for complete URLs.

Someone who knows more about this may know the best practice for this stuff!

Love the module,
Thanks,
-Tony

Comments

ila’s picture

hy, I tried your suggestion, I installed version 6.x-4.x-dev of brilliant gallery, which already has the correct code for the character "&", but the validator finds me still the same error. Any suggestions?
You can see here the problem:
http://www.culturaservizi.it/museo_virtuale_sudsalento/bvee016931
thanks in advance