Skip to content

Commit

Permalink
mvc:javascript:SimpleFileUploadDlg() - load csv as text to prevent en…
Browse files Browse the repository at this point in the history
…coding isssues, closes #8169
  • Loading branch information
AdSchellevis committed Dec 27, 2024
1 parent bbfd1f3 commit b8e3015
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/opnsense/www/js/opnsense_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ $.fn.SimpleFileUploadDlg = function (params) {
doinp.data('filename', fileinp.val().split('\\').pop());
doinp.show();
};
reader.readAsBinaryString(evt.target.files[0]);
reader.readAsText(evt.target.files[0]);
}
});
let dialog = BootstrapDialog.show({
Expand All @@ -688,7 +688,7 @@ $.fn.SimpleFileUploadDlg = function (params) {
if (data.validations && data.validations.length > 0) {
// When validation errors are returned, write to textarea including original data lines.
let output = [];
let records = params.payload.split('\n');
let records = eparams.payload.split('\n');
records.shift();
for (r=0; r < records.length; ++r) {
let found = false;
Expand Down

4 comments on commit b8e3015

@fichtner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I would not have expected JS but makes sense. 😊

@AdSchellevis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fichtner something was suspicious, just had a gut feeling :), while trying it on my end, the eparams also popped up (should have mentioned that in the commit, but forgot)

@fichtner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed there are two more of those:

% git grep reader.readAsBinaryString
src/opnsense/mvc/app/views/OPNsense/CaptivePortal/index.volt:                reader.readAsBinaryString(evt.target.files[0]);
src/opnsense/mvc/app/views/OPNsense/Firewall/alias.volt:                          reader.readAsBinaryString($imp_file[0].files[0]);

@AdSchellevis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fichtner should be safe to replace, but given nobody complained in years, I also don't mind waiting for an actual report and avoid the additional testing now.

Please sign in to comment.