Closed Bug 1453647 Opened 2 years ago Closed 2 years ago

Unicode script as passed via -e into xpcshell isn't evaluated as UTF-8

Categories

(Core :: XPConnect, enhancement)

60 Branch
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Noticed while working on bug 1453596. When a script like in this case for Mochitests contains a unicode path, it cannot be accessed from inside an executed script by xpcshell because it's not found. James and Ted helped me to find the underlying cause:

<jgraham> https://searchfox.org/mozilla-central/source/js/xpconnect/src/XPCShellImpl.cpp#971
<@ted> whimboo: yuck
<whimboo> ted: i will have a look, but is there someone I could ask?
<jgraham> I think you  want to set opts.utf8 on the JSCOntext
<jgraham> https://searchfox.org/mozilla-central/source/js/src/jsapi.cpp#4830
<jgraham> I mean generally the problem here is that the input could be any byte sequence and it doesn't have a defined encoding
<whimboo> hm, interesting
<whimboo> let me try that. thanks
<@ted> jgraham: yeah i was just going to suggest that
<@ted> jgraham: but! turns out someone thought of that and on windows argv** is already utf-8
<@ted> and on linux/macos we already assume the system encoding is utf-8 everywhere anyway
<@ted> https://searchfox.org/mozilla-central/source/js/xpconnect/shell/xpcshell.cpp#22
<@ted> https://searchfox.org/mozilla-central/source/toolkit/xre/nsWindowsWMain.cpp#109
<@ted> so yeah, calling opts.setUTF8(true) should fix that
I verified that this patch works like a charm. Will upload a patch in a minute.
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Comment on attachment 8967400 [details]
Bug 1453647 - [xpcshell] Enforce utf-8 for evaluating injected script via -e argument.

https://reviewboard.mozilla.org/r/236088/#review241884
Attachment #8967400 - Flags: review?(bzbarsky) → review+
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6d0f20a4aa1f
[xpcshell] Enforce utf-8 for evaluating injected script via -e argument. r=bz
https://hg.mozilla.org/mozilla-central/rev/6d0f20a4aa1f
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.