ini
ini copied to clipboard
"=" character not escaped properly
Version
go1.19.3 linux/amd64
Describe the bug
If a value contains the "=" character, the library will write it to the output file without escaping it. This causes PHP to fail when attempting to load the .ini file with the error
PHP Warning: syntax error, unexpected '=' in test.ini on line 27
To reproduce
writeini.go:
package main
import (
"github.com/go-ini/ini"
)
func main() {
f := ini.Empty()
test, _ := f.NewSection("test")
_, _ = test.NewKey("test", "=")
_ = f.SaveTo("./test.ini")
}
testini.php:
<?php
$ini_array = parse_ini_file("test.ini", true);
print_r($ini_array);
$ go run writeini.go
$ php testini.php
PHP Warning: syntax error, unexpected '=' in test.ini on line 2
in ~/testini.php on line 2
Expected behavior
The library should wrap values with = characters in quotes, like it does for other characters
Additional context
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
You could try wrapping the variable with backticks
example:
[test]
test=#=/