From 912011d008f0f48f5d9e908375ea13e48b239c56 Mon Sep 17 00:00:00 2001
From: Ludovico de Nittis <ludovico.denittis@collabora.com>
Date: Mon, 18 Jan 2021 14:32:04 +0100
Subject: [PATCH] wrap: parse env-if-host options as filenames instead of
 strings

If we parse the "env-if-host" options as "G_OPTION_ARG_STRING_ARRAY",
Glib assumes them to be encoded with the current locale. This can be an
issue when pressure-vessel needs to run the main game, because Steam
will set "LC_ALL=C", but the "env-if-host" might still contain
characters that are not ASCII.
To solve this we use "G_OPTION_ARG_FILENAME_ARRAY" that treats the
options as opaque byte-blobs.

Fixes: #52
Fixes: steam-runtime#349

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 pressure-vessel/wrap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c
index 2aa1bac8a..45ccf696d 100644
--- a/pressure-vessel/wrap.c
+++ b/pressure-vessel/wrap.c
@@ -972,7 +972,7 @@ static GOptionEntry options[] =
     "[Default: $PRESSURE_VESSEL_COPY_RUNTIME_INTO or empty]",
     "DIR" },
   { "env-if-host", '\0',
-    G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING_ARRAY, &opt_env_if_host,
+    G_OPTION_FLAG_NONE, G_OPTION_ARG_FILENAME_ARRAY, &opt_env_if_host,
     "Set VAR=VAL if COMMAND is run with /usr from the host system, "
     "but not if it is run with /usr from RUNTIME.", "VAR=VAL" },
   { "filesystem", '\0',
-- 
GitLab