From 92e1b64d03ab938330aa79673e0e6c57eaf080a2 Mon Sep 17 00:00:00 2001 From: xinmotlanthua Date: Thu, 16 Apr 2026 01:10:22 +0700 Subject: [PATCH] fix: preserve Generic investment subtypes in account creation form (#1465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Addressable RegExp Denial of Service * fix: preserve Generic investment subtypes in account creation form The .compact call in Investment.subtypes_grouped_for_select removed all nil values from the region order array, which inadvertently excluded Generic subtypes (region: nil) from the dropdown for all users regardless of currency setting. Replace .compact with conditional logic that preserves nil in the region order while still handling the user_region placement. Closes #1446 * Breakage on `main` reverted * style: fix SpaceInsideArrayLiteralBrackets lint offense Add spaces inside array literal brackets to match project Rubocop rules. --------- Co-authored-by: Juan José Mata Co-authored-by: khanhkhanhlele --- app/models/investment.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/investment.rb b/app/models/investment.rb index 3d18a8334..2ff1bde2f 100644 --- a/app/models/investment.rb +++ b/app/models/investment.rb @@ -102,7 +102,11 @@ class Investment < ApplicationRecord # Build region order: user's region first (if known), then Generic, then others other_regions = %w[us uk ca au eu] - [ user_region ].compact - region_order = [ user_region, nil, *other_regions ].compact.uniq + region_order = if user_region + [ user_region, nil, *other_regions ].uniq + else + [ nil, *other_regions ].uniq + end region_order.filter_map do |region| next unless grouped[region]