escapeValue escapes a string for shell safety using Ruby's escape_value method Ruby source: lib/java_buildpack/framework/java_opts.rb:61-67 str.gsub(%r{([^A-Za-z0-9_\-.,:/@\n$\\])}, '\\\\\\1').gsub(/\n/, "'\n'") Safe chars (not escaped): A-Za-z0-9_-.,:/@$\ All other chars are backslash-escaped,
(value string)
| 204 | // Safe chars (not escaped): A-Za-z0-9_-.,:/@$\ |
| 205 | // All other chars are backslash-escaped, including: = ( ) [ ] { } ; & | space % etc. |
| 206 | func escapeValue(value string) string { |
| 207 | if value == "" { |
| 208 | return "''" |
| 209 | } |
| 210 | |
| 211 | var result strings.Builder |
| 212 | for _, ch := range value { |
| 213 | if ch == '\n' { |
| 214 | result.WriteString("'\n'") // Special newline handling |
| 215 | continue |
| 216 | } |
| 217 | |
| 218 | if !isRubySafeChar(ch) { |
| 219 | result.WriteRune('\\') |
| 220 | } |
| 221 | result.WriteRune(ch) |
| 222 | } |
| 223 | return result.String() |
| 224 | } |
| 225 | |
| 226 | // isRubySafeChar checks if a character is in Ruby's safe set: A-Za-z0-9_-.,:/@\n$\ |
| 227 | // Note: '=' is NOT safe and will be escaped |
no test coverage detected