diff options
| -rw-r--r-- | source/shared.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0303-robustness.sh | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 7 insertions, 3 deletions
diff --git a/source/shared.c b/source/shared.c index 84ee4c8..a5c54ee 100644 --- a/source/shared.c +++ b/source/shared.c @@ -724,13 +724,11 @@ char *cgit_get_mimetype_for_filename(const char *filename) if (!file) return NULL; while (fgets(line, sizeof(line), file)) { - if (!line[0] || line[0] == '#') - continue; // A line of a mime.types file is one type followed by every // extension that maps to it. string_list_split_in_place(&fields, line, " \t\r\n", -1); string_list_remove_empty_items(&fields, 0); - if (!fields.nr) { + if (!fields.nr || fields.items[0].string[0] == '#') { string_list_clear(&fields, 0); continue; } diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 1963a2e..3f9c80d 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -449,6 +449,12 @@ test_expect_success 'a blank line in the mimetype file is skipped' ' grep "^Content-Type: image/x-cgit" tmp ' +test_expect_success 'an indented comment in the mimetype file is skipped' ' + printf " # cgt used to be image/x-old\nimage/x-cgit cgt\n" >mime.types && + CGIT_CONFIG="$PWD/mimerc" QUERY_STRING="url=rob/plain/note.cgt" cgit >tmp && + grep "^Content-Type: image/x-cgit" tmp +' + test_expect_success 'a refs page named with an id is not cached for ever' ' mkdir -p cache && { |
