Imagemap bug

ajuniper

Joined: 2006-01-11
Posts: 9
Posted: Tue, 2007-03-13 22:49

I think that I've found a bug in the imagemap code.

If the text I put in for a map entry contains a ' (single quote), then the javascript which is emitted is broken since Gallery writes something like:

<area alt="my nice Map 0" title="my nice Map 0" shape="poly" coords="1,2,3,4" onmouseover="return escape('mouse_over_label_string')">

If the mouse_over_label_string contains a ' then the quoting in the escape() call is broken and you end up with something like escape('aa's') which, not surprisingly, Javascript doesn't like.

What's worse is that the imagemap editor then is also broken and the only way out is to manually edit photos.dat to replace the ' with some other character before the page will load correctly.

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Wed, 2007-03-14 15:55

Hello,

thanks for reporting this! I will immediately work on this and make a fix.

Jens
--
Last Gallery v1 Developer and v1 translation manager.

 
ajuniper

Joined: 2006-01-11
Posts: 9
Posted: Wed, 2007-03-14 17:15

Looks like the problem is in lib/content.php line 1186 (I'm on gallery 1.5.5-pl1).

The output of $area['hover_text'] needs to be protect instances of ' using the preferred method.

 
ajuniper

Joined: 2006-01-11
Posts: 9
Posted: Wed, 2007-03-14 17:35

I guess also newlines need to be protected.

Something like

addcslashes($area['hover_text'],"\r\n'")

I guess?

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Wed, 2007-03-21 12:20

Hi,

you can either use Gallery 1.5.6-svn-b21, or use this:
...removed, due to better fix in b22

Thanks !

Jens
--
Last Gallery v1 Developer and v1 translation manager.

 
ajuniper

Joined: 2006-01-11
Posts: 9
Posted: Wed, 2007-03-21 21:55

Hi,

I don't agree with the change in lib/content.php, adding the href="#" to the area element.

With this change in place, I can no longer click on the active areas and be taken to the given hyperlink.

The rest is working fine.

Andy

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Thu, 2007-03-22 11:14

Hi Andy,

i agree fully with you.
I made a better fix in b22.

Thanks again,

Jens
--
Last Gallery v1 Developer and v1 translation manager.

 
ajuniper

Joined: 2006-01-11
Posts: 9
Posted: Mon, 2007-04-23 21:46

I think that this still might be broken.

I just (accidentally) put a newline in the image map text and I got the broken Javascript again, both for viewing and editing the image map. This required a manual edit of photos.dat to recover :-(

I think that the addslashes and htmlentities do not cover line breaks, which Javascript does not like being embedded in its data!

I think that you may need to look at using addcslashes which covers these extra characters?

Andy

PS. I've not yet upgraded to Gallery 1.6 (still on 1.5.5-pl1), so apologies if there is a more robust fix in 1.6.