IE7 ile download replaces spaces with underscore (_)
First post here so hello to all first of all

I have a question which i cant seem to find an answer for no matter how hard i search.
Basically, i just want to turn off the functionality that replaces the spaces with underscores when downloading a file from IE7.
I would think it is possible but i just cant find the answer.
Hope someone can help,
Thanks in advance,
Dave
All Replies
Hi Dave,
I have exactly the same problem with each space characters in the filename replaced by an underscore character - note this is just within the filename itself (the contents of the file are okay) during a 'file save as' download.
I notice that the # character is also replaced by an underscore.
Only upgraded to IE7 today and this is the first problem identified but I have not been able to see which option to modify.
Is this a font/language setting translation issue?
Hopefully someone will explain it to both of us!
Thanks,
Jeff.
Hi Jeff,
Glad its not just me! Did you manage to find a fix in the end?
Does anybody else know how to turn this option off?
Thanks
Dave
Hi Dave,
We too have spaces being replaced by underscores. Users of our application do a checkout (download) followed by a checkin (upload), and new files are being created in the repository rather than old ones being updated. So we too need a fix or workaround.
John
- I've come across this myself. If you are able to change the spaces to %20s then IE7 will convert them correctly. Firefox though will take them literally ( at least when using the Content-disposition header) so you will need to do this for requests from IE7 only.
We did the following in our app. ( a tomcat based document repository)
String userAgent = request.getHeader("User-Agent");
if (userAgent.contains("MSIE 7.0")) {
filename = filename.replace(" ", "%20");
}
response.addHeader("Content-disposition", "attachment;filename=\"" + filename+"\""); - Hi Dave,
Thanks so much for the help.
Late yesterday, I experimented with some other special characters and verified that # also gets replaced by a space ... and ; truncates everything in the file name to the right! So, I expanded on your solution as follows. (Delphi code)
// test for ie7.0 here, if yes
saveAsFileName := URLEncodePath(saveAsFileName);
PutHttpHeader('Content-Disposition', 'attachment; filename="' + saveAsFileName + '"');
// and the referenced function is as follows:
function UrlEncodePath(const S: string): string;
var
I: longInt;
Hex: string;
begin
result := '';
for I := 1 to Length(S) do
begin
case S
of
'a'..'z', 'A'..'Z', '0'..'9', '.', '/', ':':
result := result + S
;
'\':
result := result + '/';
else
begin
Hex := IntToHex(ord(S
), 2);
if Length(Hex) < 2 then
Hex := '0' + Hex;
result := result + '%' + Hex;
end;
end;
end;
end;
(I don't know why the light bulb, but replace it with "left brace, i right brace" (omit quotes)).
This function copies standard URL characters as is, replaces \ with /, and coverts any other character to its %hh representation.
The above worked for downloads with a space, # and ; in the file name. Can't promise it works in every situation, but I hope it might be useful to others encountering the same problem.
John Dear All
I think the question is not answer yet..
"Does anybody else know how to turn this option off?"
Help me too.. with this problem
Regards..
Hi All,
I finally managed to track down some kind of answer to if this can be switched off... and it seems it cannot.
However, there does seem to be quite a simple fix for it (along the same line of what john conway suggested above but just converts the spaces). You can read the thread here:
Thanks for all your replies.
Cheers
Dave
- We are having this issue with IE 7 and our web application. The fixes listed above seem to work when selecting "Save" from the download dialog but when selecting "Open" for e.g. a Word document, the fix breaks the filename by including the %20
in the filename.
Basically, according to our research, current options for MSIE 7 and handling filenames are:1) not encoding the headers: "Open" works, "Save as" replaces special characters by underscores2) encoding the headers: "Open" includes the encodings (e.g. %20 etc.) in the filenames and "Save as" works.Is there any workaround for these issues apart from waiting for a new version of IE 7 that hopefully fixes this issue (or starting to write a download agent in Java that ensures that the built-in mechanisms within IE 7 are not used for file downloads)?Thanks for any help - Hi Mikael,
Please let me know if you found the solution for this issue with the workaround.1) not encoding the headers: "Open" works, "Save as" replaces special characters by underscores2) encoding the headers: "Open" includes the encodings (e.g. %20 etc.) in the filenames and "Save as" works.
Thanks,
~JUDA - Microsoft claims to have a hotfix for this bug, which would solve many a user's problems. But, for some reason, I can't install it (it tells me that I don't need to install it since my computer already has newer updates). Yet, I check the DLL Microsoft includes in the hotfix and the DLL on my system (wininet.dll) and the DLL on my system is older than the DLL in the hotfix. I try to manually overwrite the DLL, but the System File Protection works way too well.
- Edited bypalswim Tuesday, February 10, 2009 9:51 PMGrammar


