Repository: fatedier/frp (language: go)

Issue:
Frp can't handle equal sign in environment variables
### Bug Description

Environment variables containing an equal sign `=` are ignored during parsing of config files.

We use meta properties to pass temporary AWS credentials to the frp server to authenticate a user. These credentials may contain an equal sign.

### frpc Version

0.39.1

### frps Version

0.39.1

### System Architecture

darwin/amd64

### Configurations

# server
``` ini
[common]
bind_port = 7000
vhost_http_port = 8000
subdomain_host = example.com

[plugin.login]
addr = localhost:3000
path = /login
ops = Login
```

# client
``` ini
[common]
server_addr = example.com
server_port = 7000
tls_enable = true
disable_custom_tls_first_byte = true
meta_access_key_id = {{ .Envs.AWS_ACCESS_KEY_ID }}
meta_secret_access_key = {{ .Envs.AWS_SECRET_ACCESS_KEY }}
meta_session_token = {{ .Envs.AWS_SESSION_TOKEN }}
disable_log_color = true

[{{ .Envs.FRP_SUBDOMAIN }}]
type = http
subdomain = test
local_port = 8080
local_ip = localhost
```

### Logs

_No response_

### Steps to reproduce

1. Create configuration file with an environment variable.
2. Set the value of this environment variable to something containing a `=`.
3. Observe that the environment variable is not correctly substituted in the configuration file.


### Affected area

- [ ] Docs
- [ ] Installation
- [ ] Performance and Scalability
- [ ] Security
- [ ] User Experience
- [ ] Test and Release
- [ ] Developer Infrastructure
- [X] Client Plugin
- [X] Server Plugin
- [ ] Extensions
- [ ] Others


Discussion / hints:
Thanks for your report. 

I find this a bug in parsing env value. I will fix this soon.

Fix patch:
diff --git a/pkg/config/value.go b/pkg/config/value.go
index 41c6c65a917..e44fbd693e1 100644
--- a/pkg/config/value.go
+++ b/pkg/config/value.go
@@ -29,11 +29,11 @@ func init() {
 	glbEnvs = make(map[string]string)
 	envs := os.Environ()
 	for _, env := range envs {
-		kv := strings.Split(env, "=")
-		if len(kv) != 2 {
+		pair := strings.SplitN(env, "=", 2)
+		if len(pair) != 2 {
 			continue
 		}
-		glbEnvs[kv[0]] = kv[1]
+		glbEnvs[pair[0]] = pair[1]
 	}
 }
 


Test patch: