mirror of
https://github.com/git/git.git
synced 2024-11-05 08:47:56 +01:00
bf197fd7ee
When we get a content-type from curl, we get the whole header line, including any parameters, and without any normalization (like downcasing or whitespace) applied. If we later try to match it with strcmp() or even strcasecmp(), we may get false negatives. This could cause two visible behaviors: 1. We might fail to recognize a smart-http server by its content-type. 2. We might fail to relay text/plain error messages to users (especially if they contain a charset parameter). This patch teaches the http code to extract and normalize just the type/subtype portion of the string. This is technically passing out less information to the callers, who can no longer see the parameters. But none of the current callers cares, and a future patch will add back an easier-to-use method for accessing those parameters. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 lines
350 B
Bash
Executable file
23 lines
350 B
Bash
Executable file
#!/bin/sh
|
|
|
|
printf "Status: 500 Intentional Breakage\n"
|
|
|
|
printf "Content-Type: "
|
|
charset=iso-8859-1
|
|
case "$PATH_INFO" in
|
|
*html*)
|
|
printf "text/html"
|
|
;;
|
|
*text*)
|
|
printf "text/plain"
|
|
;;
|
|
*charset*)
|
|
printf "text/plain; charset=utf-8"
|
|
charset=utf-8
|
|
;;
|
|
esac
|
|
printf "\n"
|
|
|
|
printf "\n"
|
|
printf "this is the error message\n" |
|
|
iconv -f us-ascii -t $charset
|