I've run into a bug using Thickbox; and it deals with Thickbox not loading an image that has a filename with a special character in it, specifically an ' (apostrophe). Once the module reads in the filename it's truncating it when it see an apostrophe and not escaping it out.

The image.module seems to handle filenames with special characters like apostrophes just fine. I know it's not ideal to have spaces and special character in filenames, but users seem to come up with these sorts of things, it would be nice if the module can project against this sort of failure.

Comments

slayerment’s picture

I'm having this same issue (spaces in filenames). Is there any type of way to fix this?

Thanks!

eferraiuolo’s picture

In the latest version of Thinbox, submitted on 04/06/2007 I don't have a problem with spaces in the filenames of image, but still there's an issue with ' (apostrophe). I was just needed this fixed to hedge against the risk that users would name their files with these sorts of special characters, as my test data for a project had filenames like this.

konsumer’s picture

Status: Active » Needs review

I fixed this by editting thickbox.js

I replaced the " ' " with \" in the code, and added a replace for ' " ' in the url string.

on line 113:

$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>");

is changed to:

 $("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src=\""+url.replace('"','\"')+"\" width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>");

A possibly "better" solution would be URL encoding before it gets to this point, so that all listings will work, without having to account for this contingency.

so
this is a "image" -'test'.jpg
would translate to
this%20is%20a%20%22image%22%20-%20%27test%27.jpg

I'm not quite sure where to put the translation code, though,

sun’s picture

This is a Drupal core issue. You definitely should test Transliterate filenames module. Please report back if that module works for you (and mark this issue fixed if it does).

konsumer’s picture

Status: Needs review » Closed (fixed)

works great. Much better solution.