Skip to content

Commit 8f44fd0

Browse files
committed
Remove redundant else
1 parent c71d7d9 commit 8f44fd0

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

app/models/rake_ui/rake_task.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,11 @@ def build_rake_command(args: nil, environment: nil)
116116
# Safely escape environment variables to prevent shell injection
117117
# Only accept KEY=VALUE pairs; reject malicious tokens
118118
escaped_env = Shellwords.split(environment).map do |token|
119-
if token.match?(/\A[A-Z_][A-Z0-9_]*=.+\z/i)
120-
# Valid KEY=VALUE pattern - escape only the value
121-
key, value = token.split("=", 2)
122-
"#{key}=#{Shellwords.escape(value)}"
123-
else
124-
# Invalid format (possible injection attempt) - skip this token
125-
nil
126-
end
119+
next unless token.match?(/\A[A-Z_][A-Z0-9_]*=.+\z/i)
120+
121+
# Valid KEY=VALUE pattern - escape only the value
122+
key, value = token.split("=", 2)
123+
"#{key}=#{Shellwords.escape(value)}"
127124
end.compact.join(" ")
128125

129126
command += "#{escaped_env} " if escaped_env.present?

0 commit comments

Comments
 (0)