Index: src/json.c ================================================================== --- src/json.c +++ src/json.c @@ -566,10 +566,13 @@ rc = find_option(zCLILong ? zCLILong : zKey, zCLIShort, 1); } if(!rc && fossil_has_json()){ rc = json_getenv_cstr(zKey); + if(!rc && zCLIShort){ + rc = cson_value_get_cstr( cson_object_get( g.json.param.o, zCLIShort) ); + } } if(!rc && (argPos>=0)){ rc = json_command_arg((unsigned char)argPos); } return rc; @@ -780,14 +783,15 @@ } return g.json.authToken; } /* -** IFF json.reqPayload.o is not NULL then this returns -** cson_object_get(json.reqPayload.o,pKey), else it returns NULL. -** -** The returned value is owned by (or shared with) json.reqPayload.v. +** If g.json.reqPayload.o is NULL then NULL is returned, else the +** given property is searched for in the request payload. If found it +** is returned. The returned value is owned by (or shares ownership +** with) g.json, and must NOT be cson_value_free()'d by the +** caller. */ cson_value * json_req_payload_get(char const *pKey){ return g.json.reqPayload.o ? cson_object_get(g.json.reqPayload.o,pKey) : NULL; @@ -1227,24 +1231,10 @@ }else{ ndx = g.json.cmd.offset + ndx; return cson_string_cstr(cson_value_get_string(cson_array_get( ar, g.json.cmd.offset + ndx ))); } } - -/* -** If g.json.reqPayload.o is NULL then NULL is returned, else the -** given property is searched for in the request payload. If found it -** is returned. The returned value is owned by (or shares ownership -** with) g.json, and must NOT be cson_value_free()'d by the -** caller. -*/ -cson_value * json_payload_property( char const * key ){ - return g.json.reqPayload.o ? - cson_object_get( g.json.reqPayload.o, key ) - : NULL; -} - /* Returns the C-string form of json_auth_token(), or NULL ** if json_auth_token() returns NULL. */ char const * json_auth_token_cstr(){ Index: src/json_login.c ================================================================== --- src/json_login.c +++ src/json_login.c @@ -52,21 +52,21 @@ then ONLY a GET param of "name" will match ("n" is not recognized). If we reverse the order of the checks then both forms work. Strangely enough, the "p"/"password" check is not affected by this. */ - char const * name = cson_value_get_cstr(json_payload_property("name")); + char const * name = cson_value_get_cstr(json_req_payload_get("name")); char const * pw = NULL; char const * anonSeed = NULL; cson_value * payload = NULL; int uid = 0; /* reminder to self: Fossil internally (for the sake of /wiki) interprets paths in the form /foo/bar/baz such that P("name") == "bar/baz". This collides with our name/password checking, and thus we do some rather elaborate name=... checking. */ - pw = cson_value_get_cstr(json_payload_property("password")); + pw = cson_value_get_cstr(json_req_payload_get("password")); if( !pw ){ pw = PD("p",NULL); if( !pw ){ pw = PD("password",NULL); } @@ -99,11 +99,11 @@ }; static char seedBuffer[SeedBufLen]; cson_value const * jseed = json_getenv(FossilJsonKeys.anonymousSeed); seedBuffer[0] = 0; if( !jseed ){ - jseed = json_payload_property(FossilJsonKeys.anonymousSeed); + jseed = json_req_payload_get(FossilJsonKeys.anonymousSeed); if( !jseed ){ jseed = json_getenv("cs") /* name used by HTML interface */; } } if(jseed){