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

Incorrect use of strconv.Unquote in messages.go #324

Open
IvanWillsBI opened this issue Jun 19, 2024 · 0 comments
Open

Incorrect use of strconv.Unquote in messages.go #324

IvanWillsBI opened this issue Jun 19, 2024 · 0 comments

Comments

@IvanWillsBI
Copy link

IvanWillsBI commented Jun 19, 2024

func (m *Message) AddVariable(variable string, value interface{}) error {
	if m.variables == nil {
		m.variables = make(map[string]string)
	}

	j, err := json.Marshal(value)
	if err != nil {
		return err
	}

	encoded := string(j)
	v, err := strconv.Unquote(encoded)
	if err != nil {
		v = encoded
	}

	m.variables[variable] = v
	return nil
}

Doesn't work for boolean values or numbers (non string values, as they don't appear as ""foo"")

Therefore, in my mailgun template which uses {{#if }} handlebars, I cannot check the boolean value, as it is sent as a string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant