Commit Graph

1 Commits

Author SHA1 Message Date
Justin Van Patten 82c546d873
Fix mangled diffs of strings containing url-encoded chars ()
Fix mangled diffs of strings containing url-encoded chars

Currently, modifying a stack output that contains url-encoded characters
can lead to it showing the value as `"!(NOVERB)"` or `"!(MISSING)"`.

For example, changing a stack output `path` from `"%2F"` to `"%2f"`
shows the diff as:

```
Outputs:
  ~ path: "%!(NOVERB)F" => "%!(NOVERB)f"
```

The expected diff output should be:

```
Outputs:
  ~ path: "%2F" => "%2f"
```

This is happening because the code that emits parts of the diff is
expecting a format string. Go is trying to parse the `%` in the value as
a format string and is having problems parsing it.

The fix is to emit the parts of the diff verbatim, so it isn't treated
as a format string.

Fixes 

Note: I've done an audit of the other calls to `write` in
`object_diff.go` and all the other call sites are passing actual format
strings or constants. This was the only case where we were passing user
input as a format string.
2024-05-08 08:23:40 +00:00