]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commit
Handle non-ASCII environment variable values
authorVincent Bernat <vincent@bernat.ch>
Thu, 16 Jan 2020 10:42:06 +0000 (11:42 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 31 Jan 2020 07:43:33 +0000 (08:43 +0100)
commit5fd4907089595866a7cbebf08a0820fb054d4070
treefccfa08b38223d4f5b1f514fab1ab0e502deac99
parent08d9b4f72d8e3ff0aee64c1004beea88fb5ce004
Handle non-ASCII environment variable values

When a process has an UTF-8 character in its environment, autorandr
crashes with:

```
Unhandled exception ('utf-8' codec can't decode byte 0xab in position 0: invalid start byte). Please report this as a bug at https://github.com/phillipberndt/autorandr/issues.
Traceback (most recent call last):
  File "./autorandr.py", line 1439, in <module>
    exception_handled_main()
  File "./autorandr.py", line 1423, in exception_handled_main
    main(sys.argv)
  File "./autorandr.py", line 1203, in main
    dispatch_call_to_sessions([x for x in argv if x != "--batch"])
  File "./autorandr.py", line 1110, in dispatch_call_to_sessions
    for environ_entry in open(environ_file).read().split("\0"):
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xab in position 0: invalid start byte
```

Instead, we read the environment without decoding and convert to ASCII
explicitely. Any environment variable not decodable will just be
skipped.
autorandr.py