Fix for null characters in IPTC caption

filledvoid

Joined: 2007-09-11
Posts: 1
Posted: Tue, 2007-09-11 02:31

I use Picasa to add captions to my images, and today I noticed that some of my newer captions have a null character in them (at the end of the caption). This doesn't always cause a problem for all browsers in all cases, but it definitely doesn't work for the Ajaxian theme for the "Photo Details" that appear when an image is clicked (apparently because the summary is held in the "class" attribute of the image which is then accessed using JavaScript).

So here's a quick fix for it. I'm not sure if this is the best solution, so please let me know if there's a better way. I borrowed this method from the way that null characters are handled for EXIF data, so it seems reasonable that something similar should be done for IPTC data:

modules/exif/classes/ExifHelper.class, line 467

$result = GalleryCoreApi::convertToUtf8($result, $sourceEncoding);
$result = str_replace("\0", '', $result); // <-- Added
return $result;

So the added line just removes null characters from the resulting string. It seems to do the job, although I'm not sure if there are cases when IPTC data is suppose to have nulls in it.

Thanks!

fv