blueimp/JavaScript-Canvas-to-Blob

It is an error if there is a line break code

Closed this issue · 1 comments

The Base64, for line feed may enter every 76 characters, you must remove the line breaks in the code of standard MIME.
Trouble, I spent time in the processing of new-line code. How do may be to remove the new line code in a separate process from the original,
I think it's nice to have the treatment in your plugin.
What would you say?
I described my suggestion below.

// For line feed may enter every 76 characters, 
// remove the line break code if it was obtained from the mail object in the standard MIME.
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
    // Convert base64 to raw binary data held in a string:
    byteString = atob((dataURI.split(',')[1]).replace(/\s/g, ''));
} else {
    // Convert base64/URLEncoded data component to raw binary data:
    byteString = decodeURIComponent((dataURI.split(',')[1]).replace(/\s/g, ''));
}

Sorry if I misunderstand something here, but technically, a data URL shouldn't contain any newlines.
So if you need to pass a string containing newlines to the dataURLtoBlob method, I think you should replace the newlines first.
Please let me know if there is a use case in which a normal data URL would contain newlines.