Index: src/cgi.c ================================================================== --- src/cgi.c +++ src/cgi.c @@ -258,11 +258,11 @@ zTok = strtok_r(0, ",\"",&zPos)){} fossil_free(zBuf); if(zTok) return 1; } } - + return 0; } #endif /* @@ -465,11 +465,11 @@ ** must be made of zValue. */ void cgi_setenv(const char *zName, const char *zValue){ cgi_set_parameter_nocopy(zName, mprintf("%s",zValue)); } - + /* ** Add a list of query parameters or cookies to the parameter set. ** ** Each parameter is of the form NAME=VALUE. Both the NAME and the @@ -498,24 +498,25 @@ while( *z ){ char *zName; char *zValue; while( fossil_isspace(*z) ){ z++; } zName = z; - while( *z && *z!='=' && *z!=terminator ){ z++; } - if( *z=='=' ){ - *z = 0; - z++; - zValue = z; - while( *z && *z!=terminator ){ z++; } - if( *z ){ - *z = 0; - z++; - } + zValue = 0; + while( *z ){ + if( *z==terminator ){ + *z++ = 0; break; + } + if( !zValue && (*z=='=') ){ + *z = 0; + zValue = z+1; + } + z++; + } + if( zValue ){ dehttpize(zValue); }else{ - if( *z ){ *z++ = 0; } - zValue = ""; + zValue = zName; } if( fossil_islower(zName[0]) ){ cgi_set_parameter_nocopy(zName, zValue); } #ifdef FOSSIL_ENABLE_JSON @@ -582,11 +583,11 @@ break; } } *pz = &z[i]; get_line_from_string(pz, pLen); - return z; + return z; } /* ** Tokenize a line of text into as many as nArg tokens. Make ** azArg[] point to the start of each token. @@ -689,11 +690,11 @@ cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z); } } } } - } + } } #ifdef FOSSIL_ENABLE_JSON /* @@ -833,11 +834,11 @@ z = (char*)P("HTTP_COOKIE"); if( z ){ z = mprintf("%s",z); add_param_list(z, ';'); } - + z = (char*)P("QUERY_STRING"); if( z ){ z = mprintf("%s",z); add_param_list(z, '&'); } @@ -849,11 +850,11 @@ len = atoi(PD("CONTENT_LENGTH", "0")); g.zContentType = zType = P("CONTENT_TYPE"); if( len>0 && zType ){ blob_zero(&g.cgiIn); - if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 + if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 || strncmp(zType,"multipart/form-data",19)==0 ){ z = fossil_malloc( len+1 ); len = fread(z, 1, len, g.httpIn); z[len] = 0; cgi_trace(z); @@ -879,11 +880,11 @@ /* FIXMEs: - See if fossil really needs g.cgiIn to be set for this purpose (i don't think it does). If it does then fill g.cgiIn and refactor to parse the JSON from there. - + - After parsing POST JSON, copy the "first layer" of keys/values to cgi_setenv(), honoring the upper-case distinction used in add_param_list(). However... - If we do that then we might get a disconnect in precedence of @@ -1196,20 +1197,20 @@ for(i=0; zToken[i] && zToken[i]!='?'; i++){} if( zToken[i] ) zToken[i++] = 0; cgi_setenv("PATH_INFO", zToken); cgi_setenv("QUERY_STRING", &zToken[i]); if( zIpAddr==0 && - getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, + getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, &size)>=0 ){ zIpAddr = inet_ntoa(remoteName.sin_addr); } - if( zIpAddr ){ + if( zIpAddr ){ cgi_setenv("REMOTE_ADDR", zIpAddr); g.zIpAddr = mprintf("%s", zIpAddr); } - + /* Get all the optional fields that follow the first line. */ while( fgets(zLine,sizeof(zLine),g.httpIn) ){ char *zFieldName; char *zVal; @@ -1249,11 +1250,11 @@ cgi_init(); cgi_trace(0); } #if INTERFACE -/* +/* ** Bitmap values for the flags parameter to cgi_http_server(). */ #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ #endif /* INTERFACE */ @@ -1385,11 +1386,11 @@ /* Bury dead children */ while( waitpid(0, 0, WNOHANG)>0 ){ nchildren--; } } - /* NOT REACHED */ + /* NOT REACHED */ fossil_exit(1); #endif /* NOT REACHED */ return 0; } @@ -1473,11 +1474,11 @@ p->tm_mon %= 12; } isLeapYr = p->tm_year%4==0 && (p->tm_year%100!=0 || (p->tm_year+300)%400==0); p->tm_yday = priorDays[p->tm_mon] + p->tm_mday - 1; if( isLeapYr && p->tm_mon>1 ) p->tm_yday++; - nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + + nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + (p->tm_year+300)/400 + p->tm_yday; t = ((nDay*24 + p->tm_hour)*60 + p->tm_min)*60 + p->tm_sec; return t; } Index: src/event.c ================================================================== --- src/event.c +++ src/event.c @@ -185,11 +185,11 @@ blob_init(&comment, pEvent->zComment, -1); wiki_convert(&comment, 0, WIKI_INLINE); blob_reset(&comment); @ @
append_diff(zOld, zNew, diffFlags, pRe); @}else if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){ @ - @ %z(href("%R/fdiff?v1=%S&v2=%S",zOld,zNew))[diff] + @ %z(href("%R/fdiff?v1=%S&v2=%S&sbs=1",zOld,zNew))[diff] } @ } } @@ -455,10 +455,11 @@ u64 diffFlags; /* Flag parameter for text_diff() */ const char *zName; /* Name of the checkin to be displayed */ const char *zUuid; /* UUID of zName */ const char *zParent; /* UUID of the parent checkin (if any) */ const char *zRe; /* regex parameter */ + const char *zSbs; ReCompiled *pRe = 0; /* regex */ login_check_credentials(); if( !g.perm.Read ){ login_needed(); return; } zName = P("name"); @@ -484,11 +485,12 @@ " FROM blob, event" " WHERE blob.rid=%d" " AND event.objid=%d", rid, rid ); - sideBySide = !is_false(PD("sbs","1")); + zSbs = P("sbs"); /* Note that "sbs=1" is the default value */ + sideBySide = (zSbs==0) || ((*zSbs!=0) && !is_false(zSbs)); if( db_step(&q)==SQLITE_ROW ){ const char *zUuid = db_column_text(&q, 0); char *zTitle = mprintf("Check-in [%.10s]", zUuid); char *zEUser, *zEComment; const char *zUser; @@ -896,10 +898,11 @@ const char *zBranch; const char *zFrom; const char *zTo; const char *zRe; const char *zVerbose; + const char *zSbs; ReCompiled *pRe = 0; login_check_credentials(); if( !g.perm.Read ){ login_needed(); return; } login_anonymous_available(); @@ -913,11 +916,12 @@ } pTo = vdiff_parse_manifest("to", &ridTo); if( pTo==0 ) return; pFrom = vdiff_parse_manifest("from", &ridFrom); if( pFrom==0 ) return; - sideBySide = !is_false(PD("sbs","1")); + zSbs = P("sbs"); /* Note that "sbs=1" is the default value */ + sideBySide = (zSbs==0) || ((*zSbs!=0) && !is_false(zSbs)); zVerbose = P("v"); if( !zVerbose ){ zVerbose = P("verbose"); } if( !zVerbose ){ @@ -932,16 +936,16 @@ "%R/vdiff?from=%T&to=%T&sbs=1", zFrom, zTo); } if( sideBySide || !verboseFlag ) { style_submenu_element("Unified Diff", "udiff", - "%R/vdiff?from=%T&to=%T%s&sbs=0&v=1", + "%R/vdiff?from=%T&to=%T%s&sbs=0&v", zFrom, zTo); } style_submenu_element("Invert", "invert", "%R/vdiff?from=%T&to=%T&sbs=%d%s", zTo, zFrom, - sideBySide, (verboseFlag && !sideBySide)?"&v=1":""); + sideBySide, (verboseFlag && !sideBySide)?"&v":""); style_header("Check-in Differences"); @
checkin_description(ridFrom); @
checkin_description(ridTo); @@ -1246,21 +1250,22 @@ int isPatch; int sideBySide; Blob c1, c2, diff, *pOut; char *zV1; char *zV2; - const char *zRe; + const char *zRe, *zSbs; ReCompiled *pRe = 0; u64 diffFlags; const char *zStyle = "sbsdiff"; login_check_credentials(); if( !g.perm.Read ){ login_needed(); return; } v1 = name_to_rid_www("v1"); v2 = name_to_rid_www("v2"); if( v1==0 || v2==0 ) fossil_redirect_home(); - sideBySide = !is_false(PD("sbs","1")); + zSbs = P("sbs"); /* Note that "sbs=1" is the default value */ + sideBySide = (zSbs==0) || ((*zSbs!=0) && !is_false(zSbs)); zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1); zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2); isPatch = P("patch")!=0; if( isPatch ){ pOut = cgi_output_blob();