-
Notifications
You must be signed in to change notification settings - Fork 421
Open
Labels
📦 🤖 gnovmIssues or PRs gnovm relatedIssues or PRs gnovm related🐞 bugSomething isn't workingSomething isn't working
Description
Something that has been bothering me for a while, but I just needed to come up with a MVP.
package main
func main() {
x := map[any]string{}
k1 := [2]string{"hi,wor", "ld"}
k2 := [2]string{"hi", "wor,ld"}
x[k1] = "123"
x[k2] = "456"
println(x)
}
// Output:
// map{(array[("hi,wor" string),("ld" string)] [2]string):("456" string)}
Note the single value printed, in spite of the two keys.
ComputeMapKey yields the same value ([2]string:[hi,wor,ld]
), so it's easy to trick.
More examples:
package main
func main() {
x := map[any]string{}
k1 := [2]any{"hi,string:wor", "ld"}
k2 := [2]any{"hi", "wor,string:ld"}
x[k1] = "123"
x[k2] = "456"
println(x)
}
The easiest way is probably to make strings have a length prefix, which I think should make it impossible to make strings "escape" properly.
omarsyltzmaxwell
Metadata
Metadata
Assignees
Labels
📦 🤖 gnovmIssues or PRs gnovm relatedIssues or PRs gnovm related🐞 bugSomething isn't workingSomething isn't working
Type
Projects
Status
Triage