Closed Bug 1763258 Opened 3 years ago Closed 3 years ago

cannot import big files, String.fromCharCode(...(await IOUtils.read(file.path)) fails

Categories

(MailNews Core :: Security: OpenPGP, defect)

defect

Tracking

(thunderbird_esr91 unaffected, thunderbird100+ fixed)

RESOLVED FIXED
101 Branch
Tracking Status
thunderbird_esr91 --- unaffected
thunderbird100 + fixed

People

(Reporter: KaiE, Assigned: mkmelin)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Bug 1677088 replaced file reading code, and changed it to this syntax in several places:

String.fromCharCode(...(await IOUtils.read(file.path))

When attempting to import a 2 MB file, the code fails:

RangeError: too many function arguments
    EnigmailCommon_importObjectFromFile chrome://openpgp/content/ui/commonWorkflows.js:144

Can you please change all places with this approach to use code that supports bigger files?

This seems to work:

-      keyBlock = String.fromCharCode(...(await IOUtils.read(file.path)));
+
+      let data = await IOUtils.read(file.path);
+
+      keyBlock = "";
+      for (let i = 0; i < data.length; i++) {
+        keyBlock += String.fromCharCode(data[i]);
+      }
Flags: needinfo?(mkmelin+mozilla)

I'll take care of it. What an annoying trap!

Assignee: nobody → mkmelin+mozilla
Status: NEW → ASSIGNED
Flags: needinfo?(mkmelin+mozilla)

String.fromCharCode doesn't like getting passed too many arguments, like one gets for megabytes of data.

please uplift to beta

Target Milestone: --- → 101 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/3116051508f0
fix importing of large openpgp key files. r=kaie

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED

Comment on attachment 9271233 [details]
Bug 1763258 - fix importing of large openpgp key files. r=kaie

[Triage Comment]
Approved for beta per Kai's request in comment 5.

Attachment #9271233 - Flags: approval-comm-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: