X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=package%2Fuhttpd%2Fsrc%2Fuhttpd-file.c;fp=package%2Fuhttpd%2Fsrc%2Fuhttpd-file.c;h=81f66a34b0250c81890152587ab828b569fb89f6;hb=4916211814ff2e0f7a5647c0c40bb142313c3acd;hp=2a06f85206255de0cc8129e679e9d9fd7edd542a;hpb=bd8f4ba347dad55df5b968143a72c1eac9a5963e;p=openwrt-10.03%2F.git diff --git a/package/uhttpd/src/uhttpd-file.c b/package/uhttpd/src/uhttpd-file.c index 2a06f8520..81f66a34b 100644 --- a/package/uhttpd/src/uhttpd-file.c +++ b/package/uhttpd/src/uhttpd-file.c @@ -29,23 +29,21 @@ static const char * uh_file_mime_lookup(const char *path) { struct mimetype *m = &uh_mime_types[0]; - char *p, *pd, *ps; + char *e; - ps = strrchr(path, '/'); - pd = strrchr(path, '.'); - - /* use either slash or dot as separator, whatever comes last */ - p = (ps && pd && (ps > pd)) ? ps : pd; - - if( (p != NULL) && (*(++p) != 0) ) + while( m->extn ) { - while( m->extn ) + e = &path[strlen(path)-1]; + + while( e >= path ) { - if( ! strcasecmp(p, m->extn) ) + if( (*e == '.') && !strcasecmp(&e[1], m->extn) ) return m->mime; - m++; + e--; } + + m++; } return "application/octet-stream";