Index: src/json_dir.c ================================================================== --- src/json_dir.c +++ src/json_dir.c @@ -83,33 +83,17 @@ "Checkin name [%s] is unresolved.", zCI); return NULL; } } - zDV = json_req_payload_get("name"); - if(!zDV){ - zDV = cson_object_get( g.json.param.o, "name" ); - if(!zDV && !g.isHTTP){ - zDX = json_command_arg(g.json.dispatchDepth+1); - } - } - if(!zDX){ - zDX = zDV ? cson_value_get_cstr(zDV) : NULL; - } + zDX = json_find_option_cstr("name",NULL,NULL); if(!zDX && !g.isHTTP){ - zDX = json_find_option_cstr("name",NULL,"n"); + zDX = json_command_arg(g.json.dispatchDepth+1); } -#if 1 if(zDX && (!*zDX || (0==strcmp(zDX,"/")))){ zDX = NULL; } -#endif -#if 0 - if(!zDX || !*zDX){ - zDX = "/"; - } -#endif zD = zDX ? fossil_strdup(zDX) : NULL; nD = zD ? strlen(zD)+1 : 0; while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; } sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0, Index: src/json_wiki.c ================================================================== --- src/json_wiki.c +++ src/json_wiki.c @@ -232,25 +232,11 @@ if( !g.perm.RdWiki && !g.perm.Read ){ json_set_err(FSL_JSON_E_DENIED, "Requires 'o' or 'j' access."); return NULL; } - zPageName = json_find_option_cstr("name",NULL,"n") - /* Damn... fossil automatically sets name to the PATH - part after /json, so we need a workaround down here.... - */ - ; - if( zPageName && (NULL != strstr(zPageName, "/"))){ - /* Assume that we picked up a path remnant. */ - zPageName = NULL; - } - if( !zPageName && cson_value_is_string(g.json.reqPayload.v) ){ - zPageName = cson_string_cstr(cson_value_get_string(g.json.reqPayload.v)); - } - if(!zPageName){ - zPageName = json_command_arg(g.json.dispatchDepth+1); - } + zPageName = json_find_option_cstr2("name",NULL,"n",g.json.dispatchDepth+1); zSymName = json_find_option_cstr("uuid",NULL,"u"); if((!zPageName||!*zPageName) && (!zSymName || !*zSymName)){ json_set_err(FSL_JSON_E_MISSING_ARGS, @@ -336,10 +322,15 @@ json_set_err( FSL_JSON_E_MISSING_ARGS, "'name' parameter is missing."); return NULL; } zPageName = cson_string_cstr(cson_value_get_string(nameV)); + if(!zPageName || !*zPageName){ + json_set_err(FSL_JSON_E_INVALID_ARGS, + "'name' parameter must be a non-empty string."); + return NULL; + } rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" " ORDER BY x.mtime DESC LIMIT 1", zPageName @@ -370,11 +361,11 @@ } } if( !cson_value_is_string(nameV) || !cson_value_is_string(contentV)){ json_set_err(FSL_JSON_E_INVALID_ARGS, - "'name' and 'content' parameters must be strings."); + "'content' parameter must be a string."); goto error; } jstr = cson_value_get_string(contentV); contentLen = (int)cson_string_length_bytes(jstr); if(contentLen){