MakeDisposition generates an HTTP Content-Disposition field-value. Similar solution followed by: Spring(Java), Symfony(PHP) and Ruby on Rails frameworks too. Fixes CVE-2020-5398. Reported by motoyasu-saburi.
(filename string)
| 5530 | // |
| 5531 | // Fixes CVE-2020-5398. Reported by motoyasu-saburi. |
| 5532 | func MakeDisposition(filename string) string { |
| 5533 | return `attachment; filename*=UTF-8''` + url.QueryEscape(filename) |
| 5534 | } /* |
| 5535 | // Found at: https://stackoverflow.com/questions/53069040/checking-a-string-contains-only-ascii-characters |
| 5536 | // A faster (better, more idiomatic) version, which avoids unnecessary rune conversions. |
| 5537 | func isASCII(s string) bool { |
no outgoing calls
no test coverage detected
searching dependent graphs…