From 0713265fd15f5ce0d6e86e620a2de254ff291f81 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Thu, 29 Dec 2016 10:40:47 -0500 Subject: Use `next` instead of `break`; avoid terminating whole loop We want to avoid terminating the whole loop here, because it will cause parameters that should be removed to not be removed, since we are terminating early. In this specific case, `param2` is processed before `param1` due to the reversing of `route.parts`, and since `param2` fails the check on this line, it would previously cause the whole loop to fail, and `param1` would still be in `parameterized_parts`. Now, we are simply calling `next`, which is the intended behavior. Introduced by 8ca8a2d773b942c4ea76baabe2df502a339d05b1. Fixes #27454. --- actionpack/lib/action_dispatch/journey/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index 1d239addf8..f3b8e82d32 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -36,7 +36,7 @@ module ActionDispatch route.parts.reverse_each do |key| break if defaults[key].nil? && parameterized_parts[key].present? - break if parameterized_parts[key].to_s != defaults[key].to_s + next if parameterized_parts[key].to_s != defaults[key].to_s break if required_parts.include?(key) parameterized_parts.delete(key) -- cgit v1.2.3