does not encode newlines or backticks
(s string)
| 52 | |
| 53 | // does not encode newlines or backticks |
| 54 | func HardQuoteFish(s string) string { |
| 55 | if s == "" { |
| 56 | return "\"\"" |
| 57 | } |
| 58 | |
| 59 | if safePattern.MatchString(s) { |
| 60 | return s |
| 61 | } |
| 62 | |
| 63 | if !checkQuoteSize(s) { |
| 64 | return "" |
| 65 | } |
| 66 | |
| 67 | buf := make([]byte, 0, len(s)+5) |
| 68 | buf = append(buf, '"') |
| 69 | |
| 70 | for i := 0; i < len(s); i++ { |
| 71 | switch s[i] { |
| 72 | case '"', '\\', '$': |
| 73 | buf = append(buf, '\\', s[i]) |
| 74 | default: |
| 75 | buf = append(buf, s[i]) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | buf = append(buf, '"') |
| 80 | return string(buf) |
| 81 | } |
| 82 | |
| 83 | func HardQuotePowerShell(s string) string { |
| 84 | if s == "" { |
no test coverage detected