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

Upload doesn’t work when non-english characters are presented in the filename #128

Closed
PeterMozesMerl opened this issue Oct 29, 2015 · 3 comments

Comments

@PeterMozesMerl
Copy link

Upload doesn’t work with either über.png or éber.png. These are valid characters in file names.

Uncaught SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'éber.png' is not a valid HTTP header field value.

Chrome says it’s line 1499 on the demo site.

Note: I have an (~1-2 years) old version of Simple-Ajax-Uploader in production. Fortunately, it has no problem with the same file.

@PeterMozesMerl
Copy link
Author

Unfortunately, I had no time to read the whole source code, so I’m wondering if there is a reason to not always encode the filename.

headers['X-File-Name'] = !this._opts.encodeCustomHeaders ? fileObj.name : encodeURIComponent( fileObj.name );

I think removing the condition and using the latter arm from the line above would solve the issue. Would this conflict with the line 1499 area? (Below)

if ( opts.encodeCustomHeaders && opts.customHeaders.hasOwnProperty( i ) ) {
    xhr.setRequestHeader( i, encodeURIComponent( headers[ i ] ) + '' );
} else {
    xhr.setRequestHeader( i, headers[ i ] + '' );
}

@LPology
Copy link
Owner

LPology commented Dec 24, 2015

I just renamed files to both über.png and éber.png and it worked fine. Are you setting charset=UTF-8 on your page?

Can you try it on the demo and let me know what happens?

https://www.lpology.com/code/ajaxuploader/

@LPology
Copy link
Owner

LPology commented Dec 29, 2015

Fixed with 2.3 release. Closing out. Feel free to reopen if you have any issues.

@LPology LPology closed this as completed Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants