This project is archived and is in readonly mode.
OrderedHash mishandles keys
-
Brandon Keepers
Attached is a patch that fixes these two issues, and probably a few more.
-
Frederick Cheung
- Tag changed from activesupport, hash to activesupport, hash, patch
Is the dup in initialize_copy not redundant given that keys already does a dup? Other than that looks sane to me.
-
Brandon Keepers
Yeah, it is redundant, but I thought it more clearly communicated the intent. I'm ok with removing it, I just didn't want people to be confused about it's just setting the instance variable to the value of keys.
-
Frederick Cheung
I'd remove it. If anything (for me at least) it adds confusion (' I thought the return value of keys was safe to mess around with but it's dup-ing it here, should I always dup it myself ? ').
There might be other bugs like this. When I rewrote OrderedHash a few weeks ago I was mostly worried about backwards compatibility with the existing implementation (when it was an array with knobs on) so I didn't worry to much about methods that didn't exist on the old OrderedHash.
-
Brandon Keepers
Updated patch that removes the unnecessary dup
-
Repository
- State changed from new to resolved
(from [452cd74d81ecfa38d0c7d3a4dc83d2b731de9e73]) Dup keys in OrderedHash to prevent them from being modified [#1676 OrderedHash mishandles keys state:resolved]
Signed-off-by: Frederick Cheung frederick.cheung@gmail.com http://github.com/rails/rails/co...
