Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"=" character not escaped properly #332

Open
1 task done
Tim-Blyth-SiteHost opened this issue Nov 30, 2022 · 1 comment
Open
1 task done

"=" character not escaped properly #332

Tim-Blyth-SiteHost opened this issue Nov 30, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Tim-Blyth-SiteHost
Copy link

Tim-Blyth-SiteHost commented Nov 30, 2022

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

  • I agree to follow this project's Code of Conduct
@Tim-Blyth-SiteHost Tim-Blyth-SiteHost added the bug Something isn't working label Nov 30, 2022
@awanganddong
Copy link

You could try wrapping the variable with backticks

example:
[test]
test=#=/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants