hashicorp / hashicorp/hcl

Using gohcl, escape characters required for HCL parsing remain in the decoded string field

Open
#304 5 comments 0 reactions 0 assignees View on GitHub
bug syntax/native v2
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Given the following string in HCL2 the \\ required to parse \/:

`"^whatever\\/.*$"`

When decoding with gohcl into a struct the resulting string within the struct still contains the extra \

```
Acl: (*model.Acl)(0xc4201b2080)({
Resources: ([]*model.Resource) (len=5 cap=5) {
(*model.Resource)(0xc420157d70)({
Pattern: (string) (len=13) "^whatever\\/.*$",
Permissions: ([]*model.Permission) (len=2 cap=2) {
(*model.Permission)(0xc4201b40f0)({
Authority: (string) (len=15) "role:nacho_rw",
Actions: ([]string) (len=2 cap=2) {
(string) (len=4) "pull",
(string) (len=4) "push"
}
}),
```
I would expect that the when decoding the string escape is removed?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the gohcl decoding path and reproduce the HCL2 example containing an escaped slash. Compare the decoded struct field with the expected unescaped string, then add coverage for this case and confirm the resulting value no longer contains the parsing escape.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.