rubyStyleEscape escapes a Java option exactly like the Ruby buildpack Ruby source: lib/java_buildpack/framework/java_opts.rb:40-41 .map { |java_opt| /(? .+?)=(? .+)/ =~ java_opt ? "#{key}=#{escape_value(value)}" : java_opt } Strategy: Split on first '=' and escape only the VALUE part
(javaOpt string)
| 183 | // "-Dkey=value with spaces" → "-Dkey=value\\ with\\ spaces" |
| 184 | // "-XX:OnOutOfMemoryError=kill -9 %p" → "-XX:OnOutOfMemoryError=kill\\ -9\\ \\%p" |
| 185 | func rubyStyleEscape(javaOpt string) string { |
| 186 | idx := strings.IndexByte(javaOpt, '=') |
| 187 | |
| 188 | if idx == -1 || idx == len(javaOpt)-1 { |
| 189 | return javaOpt // No '=' or ends with '=' |
| 190 | } |
| 191 | |
| 192 | key := javaOpt[:idx] |
| 193 | value := javaOpt[idx+1:] |
| 194 | |
| 195 | return key + "=" + escapeValue(value) |
| 196 | } |
| 197 | |
| 198 | // escapeValue escapes a string for shell safety using Ruby's escape_value method |
| 199 | // |
no test coverage detected