aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/lexparse.c23
-rw-r--r--src/libtipidee/tipidee_conf_get_content_type.c5
2 files changed, 17 insertions, 11 deletions
diff --git a/src/config/lexparse.c b/src/config/lexparse.c
index d5fcf6d..a799a6b 100644
--- a/src/config/lexparse.c
+++ b/src/config/lexparse.c
@@ -182,15 +182,20 @@ static inline void parse_contenttype (char const *s, size_t const *word, size_t
n-- ;
for (size_t i = 0 ; i < n ; i++)
{
- size_t len = strlen(s + word[i]) ;
- char key[len + 2] ;
- if (s[word[i]] != '.')
- strerr_dief6x(1, "file extensions must start with a dot", " - check directive content-type", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
- key[0] = 'T' ;
- key[1] = ':' ;
- memcpy(key + 2, s + word[i] + 1, len - 1) ;
- key[len + 1] = 0 ;
- add_unique(key, ct, strlen(ct) + 1, md) ;
+ if (s[word[i]] == '\"' && s[word[i]+1] == '\"' && !s[word[i]+2])
+ add_unique("T:", ct, strlen(ct) + 1, md) ;
+ else if (s[word[i]] != '.')
+ strerr_dief6x(1, "file extensions must be \"\" or start with a dot", " - check directive content-type", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
+ else
+ {
+ size_t len = strlen(s + word[i]) ;
+ char key[len + 2] ;
+ key[0] = 'T' ;
+ key[1] = ':' ;
+ memcpy(key + 2, s + word[i] + 1, len - 1) ;
+ key[len + 1] = 0 ;
+ add_unique(key, ct, strlen(ct) + 1, md) ;
+ }
}
}
diff --git a/src/libtipidee/tipidee_conf_get_content_type.c b/src/libtipidee/tipidee_conf_get_content_type.c
index 7ee8866..98e9f5d 100644
--- a/src/libtipidee/tipidee_conf_get_content_type.c
+++ b/src/libtipidee/tipidee_conf_get_content_type.c
@@ -7,16 +7,17 @@
char const *tipidee_conf_get_content_type (tipidee_conf const *conf, char const *res)
{
+ char const *value = 0 ;
char const *ext = strrchr(res, '.') ;
if (ext && !strchr(ext, '/'))
{
- char const *value = 0 ;
size_t extlen = strlen(ext+1) ;
char key[3 + extlen] ;
key[0] = 'T' ; key[1] = ':' ;
memcpy(key + 2, ext + 1, extlen + 1) ;
value = tipidee_conf_get_string(conf, key) ;
- if (value || errno != ENOENT) return value ;
}
+ else value = tipidee_conf_get_string(conf, "T:") ;
+ if (value || errno != ENOENT) return value ;
return "application/octet-stream" ;
}