Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 filenames are not properly handled in download SaveAs... dialogs #48

Closed
xurwxj opened this issue Apr 28, 2015 · 11 comments
Closed
Labels

Comments

@xurwxj
Copy link

xurwxj commented Apr 28, 2015

there will be garbled words for filename if any words in east asia.

victor

@vsivsi
Copy link
Owner

vsivsi commented Apr 28, 2015

The file-collection package doesn't modify the filename in any way. The filename completely belongs to the developer/application. Are you seeing this problem with the file-collection sample application?

While I appreciate you reporting issues as you see them, you need to do a little more work to give me detailed steps to reproduce what you are seeing. I can only guess how this could be happening, and I don't have time to play "20 questions" with users to figure out what's going on for each issue.

Please take the time to put together a proper bug report, with detailed steps to reproduce the error you are seeing, and I will take the time to look into it.

@xurwxj
Copy link
Author

xurwxj commented Apr 29, 2015

if filename is 'Nodejs中文指南.pdf';
https://github.com/vsivsi/meteor-file-collection/blob/master/http_access_server.coffee#L184
should change to :

var userAgent = (req.headers['user-agent']||'').toLowerCase();

if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
    headers['Content-Disposition'] = 'attachment; filename=' + encodeURIComponent(filename);
} else if(userAgent.indexOf('firefox') >= 0) {
    headers['Content-Disposition'] = 'attachment; filename*="utf8\'\'' + encodeURIComponent(filename)+'"';
} else {
    /* safari and other browsers */
    headers['Content-Disposition'] = 'attachment; filename=' + new Buffer(filename).toString('binary');
}

if not change, the filename in download dialog will be garbled.

@vsivsi
Copy link
Owner

vsivsi commented Apr 29, 2015

Okay, I misunderstood and thought you were referring to the gridFS filename attribute stored in MongoDB. Thanks for the additional information. I'll look into this today.

@vsivsi vsivsi changed the title need fix filename with east asia words existed when download Unicode filenames specified in URL query are not properly handled Apr 29, 2015
@vsivsi vsivsi changed the title Unicode filenames specified in URL query are not properly handled UTF-8 filenames are not properly handled in dowllad SaveAs... dialogs Apr 29, 2015
@vsivsi vsivsi changed the title UTF-8 filenames are not properly handled in dowllad SaveAs... dialogs UTF-8 filenames are not properly handled in download SaveAs... dialogs Apr 29, 2015
@vsivsi vsivsi closed this as completed in ed68829 Apr 30, 2015
@vsivsi
Copy link
Owner

vsivsi commented Apr 30, 2015

@xurwxj Just committed a fix for this based on: http://stackoverflow.com/a/20933751
Thanks for reporting this issue!

@xurwxj
Copy link
Author

xurwxj commented Apr 30, 2015

update on v1.0.6?
problem still exist in v1.0.6

victor

@vsivsi
Copy link
Owner

vsivsi commented Apr 30, 2015

Yes, 1.0.6 has the fix. What browser are you using?

@xurwxj
Copy link
Author

xurwxj commented Apr 30, 2015

mac 10.10
google chrome Version 42.0.2311.90 (64-bit)

following browser is ok:
safari Version 8.0.5 (10600.5.17)
firefox 37.0.1

@vsivsi
Copy link
Owner

vsivsi commented Apr 30, 2015

Just tried it on OSX 10.10 with Chrome 42.0.2311.135 and it works just fine...

@xurwxj
Copy link
Author

xurwxj commented Apr 30, 2015

upgrade chrome to 42.0.2311.135 and problem still exist when works fine in firefox and safari.
but strange when works fine with sample app.

thanks
i'll find it myself.

@vsivsi
Copy link
Owner

vsivsi commented Apr 30, 2015

Do you see this problem in Chrome with the sample app? It works perfectly for me.

screen shot 2015-04-29 at 7 26 35 pm

@CubetaX
Copy link

CubetaX commented Dec 11, 2018

if filename is 'Nodejs中文指南.pdf';
https://github.com/vsivsi/meteor-file-collection/blob/master/http_access_server.coffee#L184
should change to :

var userAgent = (req.headers['user-agent']||'').toLowerCase();

if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) {
    headers['Content-Disposition'] = 'attachment; filename=' + encodeURIComponent(filename);
} else if(userAgent.indexOf('firefox') >= 0) {
    headers['Content-Disposition'] = 'attachment; filename*="utf8\'\'' + encodeURIComponent(filename)+'"';
} else {
    /* safari and other browsers */
    headers['Content-Disposition'] = 'attachment; filename=' + new Buffer(filename).toString('binary');
}

if not change, the filename in download dialog will be garbled.

I dont know why safari setting must be a binary..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants