Fossil SCM

Attempt to fix 'CONTENT_TYPE' detection when a suffix, e.g. '; charset=utf-8', is present.

mistachkin 2019-08-27 06:50 noJsonCgiFlag
Commit 891bbc6ffeb7b10e6d53a67d6f9c650ea7b1039ebdc4d6c06c38992fb2520e57
2 files changed +9 -1 +1
+9 -1
--- src/cgi.c
+++ src/cgi.c
@@ -959,10 +959,11 @@
959959
** PATH_INFO when it is empty.
960960
*/
961961
void cgi_init(void){
962962
char *z;
963963
const char *zType;
964
+ char *zSemi;
964965
int len;
965966
const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
966967
const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
967968
const char *zPathInfo = cgi_parameter("PATH_INFO",0);
968969
@@ -1005,11 +1006,18 @@
10051006
if( z ){
10061007
g.zIpAddr = mprintf("%s", z);
10071008
}
10081009
10091010
len = atoi(PD("CONTENT_LENGTH", "0"));
1010
- g.zContentType = zType = P("CONTENT_TYPE");
1011
+ zType = P("CONTENT_TYPE");
1012
+ zSemi = zType ? strchr(zType, ';') : 0;
1013
+ if( zSemi ){
1014
+ g.zContentType = mprintf("%.*s", zSemi-zType, zType);
1015
+ zType = g.zContentType;
1016
+ }else{
1017
+ g.zContentType = zType;
1018
+ }
10111019
blob_zero(&g.cgiIn);
10121020
if( len>0 && zType ){
10131021
if( fossil_strcmp(zType, "application/x-fossil")==0 ){
10141022
blob_read_from_channel(&g.cgiIn, g.httpIn, len);
10151023
blob_uncompress(&g.cgiIn, &g.cgiIn);
10161024
--- src/cgi.c
+++ src/cgi.c
@@ -959,10 +959,11 @@
959 ** PATH_INFO when it is empty.
960 */
961 void cgi_init(void){
962 char *z;
963 const char *zType;
 
964 int len;
965 const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
966 const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
967 const char *zPathInfo = cgi_parameter("PATH_INFO",0);
968
@@ -1005,11 +1006,18 @@
1005 if( z ){
1006 g.zIpAddr = mprintf("%s", z);
1007 }
1008
1009 len = atoi(PD("CONTENT_LENGTH", "0"));
1010 g.zContentType = zType = P("CONTENT_TYPE");
 
 
 
 
 
 
 
1011 blob_zero(&g.cgiIn);
1012 if( len>0 && zType ){
1013 if( fossil_strcmp(zType, "application/x-fossil")==0 ){
1014 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
1015 blob_uncompress(&g.cgiIn, &g.cgiIn);
1016
--- src/cgi.c
+++ src/cgi.c
@@ -959,10 +959,11 @@
959 ** PATH_INFO when it is empty.
960 */
961 void cgi_init(void){
962 char *z;
963 const char *zType;
964 char *zSemi;
965 int len;
966 const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
967 const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
968 const char *zPathInfo = cgi_parameter("PATH_INFO",0);
969
@@ -1005,11 +1006,18 @@
1006 if( z ){
1007 g.zIpAddr = mprintf("%s", z);
1008 }
1009
1010 len = atoi(PD("CONTENT_LENGTH", "0"));
1011 zType = P("CONTENT_TYPE");
1012 zSemi = zType ? strchr(zType, ';') : 0;
1013 if( zSemi ){
1014 g.zContentType = mprintf("%.*s", zSemi-zType, zType);
1015 zType = g.zContentType;
1016 }else{
1017 g.zContentType = zType;
1018 }
1019 blob_zero(&g.cgiIn);
1020 if( len>0 && zType ){
1021 if( fossil_strcmp(zType, "application/x-fossil")==0 ){
1022 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
1023 blob_uncompress(&g.cgiIn, &g.cgiIn);
1024
--- src/style.c
+++ src/style.c
@@ -1198,10 +1198,11 @@
11981198
@ g.zTop = %h(g.zTop)<br />
11991199
@ g.zPath = %h(g.zPath)<br />
12001200
@ g.userUid = %d(g.userUid)<br />
12011201
@ g.zLogin = %h(g.zLogin)<br />
12021202
@ g.isHuman = %d(g.isHuman)<br />
1203
+ @ g.cgiUpperParamsOk = %d(g.cgiUpperParamsOk)<br />
12031204
if( g.nRequest ){
12041205
@ g.nRequest = %d(g.nRequest)<br />
12051206
}
12061207
if( g.nPendingRequest>1 ){
12071208
@ g.nPendingRequest = %d(g.nPendingRequest)<br />
12081209
--- src/style.c
+++ src/style.c
@@ -1198,10 +1198,11 @@
1198 @ g.zTop = %h(g.zTop)<br />
1199 @ g.zPath = %h(g.zPath)<br />
1200 @ g.userUid = %d(g.userUid)<br />
1201 @ g.zLogin = %h(g.zLogin)<br />
1202 @ g.isHuman = %d(g.isHuman)<br />
 
1203 if( g.nRequest ){
1204 @ g.nRequest = %d(g.nRequest)<br />
1205 }
1206 if( g.nPendingRequest>1 ){
1207 @ g.nPendingRequest = %d(g.nPendingRequest)<br />
1208
--- src/style.c
+++ src/style.c
@@ -1198,10 +1198,11 @@
1198 @ g.zTop = %h(g.zTop)<br />
1199 @ g.zPath = %h(g.zPath)<br />
1200 @ g.userUid = %d(g.userUid)<br />
1201 @ g.zLogin = %h(g.zLogin)<br />
1202 @ g.isHuman = %d(g.isHuman)<br />
1203 @ g.cgiUpperParamsOk = %d(g.cgiUpperParamsOk)<br />
1204 if( g.nRequest ){
1205 @ g.nRequest = %d(g.nRequest)<br />
1206 }
1207 if( g.nPendingRequest>1 ){
1208 @ g.nPendingRequest = %d(g.nPendingRequest)<br />
1209

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button