fix: CSV upload failure

This commit is contained in:
Suraj Shetty 2021-09-17 10:28:49 +05:30
parent 39fa75cfca
commit 9a66f185e7
2 changed files with 15 additions and 5 deletions

View file

@ -835,10 +835,11 @@ export default class Grid {
$.each(row, (ci, value) => {
var fieldname = fieldnames[ci];
var df = frappe.meta.get_docfield(me.df.options, fieldname);
d[fieldnames[ci]] = value_formatter_map[df.fieldtype]
? value_formatter_map[df.fieldtype](value)
: value;
if (df) {
d[fieldnames[ci]] = value_formatter_map[df.fieldtype]
? value_formatter_map[df.fieldtype](value)
: value;
}
});
}
}

View file

@ -927,7 +927,16 @@ Object.assign(frappe.utils, {
// decodes base64 to string
let parts = dataURI.split(',');
const encoded_data = parts[1];
return decodeURIComponent(escape(atob(encoded_data)));
let decoded = atob(encoded_data);
try {
const escaped = escape(decoded);
decoded = decodeURIComponent(escaped);
} catch (e) {
// pass decodeURIComponent failure
// just return atob response
}
return decoded;
},
copy_to_clipboard(string) {
let input = $("<input>");