Skip to content
  • Jan Rybar's avatar
    Use JS_EncodeStringToUTF8 consistently with JavaScript · 2bc4e656
    Jan Rybar authored
    When strings handled by the jsbackendauthority contain non-ASCII, the
    code will fail.  For example, on a system having a user with a
    non-ASCII name, the following message will appear when a USB stick is
    plugged in.
    
    mar 04 21:47:31 mimmi polkitd[17163]: Error evaluating authorization rules
    
    The user will not be allowed to do the mount.
    
    The problem is that strings were variously encoded back to C strings
    with JS_EncodeString and JS_EncodeStringToUTF8.  According to the
    documentation
    (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_EncodeString#Description)
    the former will simply drop the high byte from each character.  If
    that happens to a username, it will no longer be found as a valid user
    name on the system.  Explicitly encoding to UTF-8 will at least work
    in UTF-8 locales, which is the increasingly dominant encoding.
    2bc4e656