Skip to content

Use JS_EncodeStringToUTF8 consistently with JavaScript

Göran Uddeborg requested to merge goeran/polkit:master into master

After upgrading polkit on my Fedora system, I was no longer allowed to do things, like mounting an USB stick. When trying, I got messages like this in the journal:

mar 04 21:47:31 mimmi polkitd[17163]: Error evaluating authorization rules

This only affected my user account, which contains a non-ASCII character. Other accounts with traditional all-ASCII names worked as before. Trying to bisect the problem, I found the last working commit was 105abaa5, and the first failing was f48b1faa, the port to mozjs52.

After trying to understand how polkit and JavaScript works, I believe the problem is that strings are variously encoded back to C strings with JS_EncodeString and JS_EncodeStringToUTF8. According to this documentation the former will simply drop the high byte from each character. When that happens to my username, it will no longer be found as a valid user name on the system. Explicitly encoding to UTF8 as in this patch seems to work, however.

Edited by Göran Uddeborg

Merge request reports