Force UTF-8 encoding of lsb_release output
It's possible that the output may be encoded ASCII-8BIT, which cannot be automatically encoded to UTF-8 by Ruby's JSON library. In this particular case, elementaryOS 6.1 returns `Jólnir` as a part of the lsb_release Description field. Ruby's IO.popen would return this whole output in ASCII-8BIT. When this description field was passed to homebrew-bundle to be written in a JSON lockfile, Ruby throws an exception because it could not automatically reencode from ASCII-8BIT to UTF-8. This may actually affect other output of the calls to the underlying `Utils.popen_read` but this may be the first thing to trigger it since JSON requires UTF-8 output and nothing else using that function may require UTF-8. Fixes #12689 12689 Fixes Homebrew/homebrew-bundle#1043
This commit is contained in:
parent
7fc2159fcd
commit
b632123d6b
@ -12,7 +12,7 @@ module OS
|
|||||||
def os_version
|
def os_version
|
||||||
if which("lsb_release")
|
if which("lsb_release")
|
||||||
lsb_info = Utils.popen_read("lsb_release", "-a")
|
lsb_info = Utils.popen_read("lsb_release", "-a")
|
||||||
description = lsb_info[/^Description:\s*(.*)$/, 1]
|
description = lsb_info[/^Description:\s*(.*)$/, 1].force_encoding("UTF-8")
|
||||||
codename = lsb_info[/^Codename:\s*(.*)$/, 1]
|
codename = lsb_info[/^Codename:\s*(.*)$/, 1]
|
||||||
if codename.blank? || (codename == "n/a")
|
if codename.blank? || (codename == "n/a")
|
||||||
description
|
description
|
||||||
|
Loading…
x
Reference in New Issue
Block a user