forked from qt-creator/qt-creator
CmdBridge: Filter out invalid environment entries
For some reason the os.Environ() would include entries like: ` =/tmp/_qtc_cmdbridge`. Those did break the linuxdevice fullLocalCommandLine(). We now filter them out both in the bridge and the device. Change-Id: If1ab6b6b762edbc402d095500e91b3689deaed73 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
@@ -402,7 +404,12 @@ func processCommand(watcher *WatcherHandler, cmd command, out chan<- []byte) {
|
||||
|
||||
|
||||
func sendEnvironment(out chan<- []byte) {
|
||||
env := os.Environ()
|
||||
// Delete all entries without a valid key.
|
||||
env := slices.DeleteFunc(os.Environ(), func(s string) bool {
|
||||
trimmed := strings.TrimSpace(s)
|
||||
return len(trimmed) == 0 || trimmed[0] == '='
|
||||
})
|
||||
|
||||
result, _ := cbor.Marshal(environment{
|
||||
Type: "environment",
|
||||
Id: -1,
|
||||
|
@@ -826,7 +826,7 @@ CommandLine SshProcessInterfacePrivate::fullLocalCommandLine() const
|
||||
|
||||
const Environment &env = q->m_setup.m_environment;
|
||||
env.forEachEntry([&](const QString &key, const QString &value, bool enabled) {
|
||||
if (enabled)
|
||||
if (enabled && !key.trimmed().isEmpty())
|
||||
inner.addArgs(key + "='" + env.expandVariables(value) + '\'', CommandLine::Raw);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user