Fossil SCM

Removed some special-case handling of "name" param (no longer needed).

stephan 2012-03-18 03:47 trunk
Commit 34fc6f098f81a40a90ea0bc899589d6401777f5d
2 files changed +2 -18 +7 -16
+2 -18
--- src/json_dir.c
+++ src/json_dir.c
@@ -83,33 +83,17 @@
8383
"Checkin name [%s] is unresolved.",
8484
zCI);
8585
return NULL;
8686
}
8787
}
88
- zDV = json_req_payload_get("name");
89
- if(!zDV){
90
- zDV = cson_object_get( g.json.param.o, "name" );
91
- if(!zDV && !g.isHTTP){
92
- zDX = json_command_arg(g.json.dispatchDepth+1);
93
- }
94
- }
95
- if(!zDX){
96
- zDX = zDV ? cson_value_get_cstr(zDV) : NULL;
97
- }
88
+ zDX = json_find_option_cstr("name",NULL,NULL);
9889
if(!zDX && !g.isHTTP){
99
- zDX = json_find_option_cstr("name",NULL,"n");
90
+ zDX = json_command_arg(g.json.dispatchDepth+1);
10091
}
101
-#if 1
10292
if(zDX && (!*zDX || (0==strcmp(zDX,"/")))){
10393
zDX = NULL;
10494
}
105
-#endif
106
-#if 0
107
- if(!zDX || !*zDX){
108
- zDX = "/";
109
- }
110
-#endif
11195
zD = zDX ? fossil_strdup(zDX) : NULL;
11296
nD = zD ? strlen(zD)+1 : 0;
11397
while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
11498
11599
sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
116100
--- src/json_dir.c
+++ src/json_dir.c
@@ -83,33 +83,17 @@
83 "Checkin name [%s] is unresolved.",
84 zCI);
85 return NULL;
86 }
87 }
88 zDV = json_req_payload_get("name");
89 if(!zDV){
90 zDV = cson_object_get( g.json.param.o, "name" );
91 if(!zDV && !g.isHTTP){
92 zDX = json_command_arg(g.json.dispatchDepth+1);
93 }
94 }
95 if(!zDX){
96 zDX = zDV ? cson_value_get_cstr(zDV) : NULL;
97 }
98 if(!zDX && !g.isHTTP){
99 zDX = json_find_option_cstr("name",NULL,"n");
100 }
101 #if 1
102 if(zDX && (!*zDX || (0==strcmp(zDX,"/")))){
103 zDX = NULL;
104 }
105 #endif
106 #if 0
107 if(!zDX || !*zDX){
108 zDX = "/";
109 }
110 #endif
111 zD = zDX ? fossil_strdup(zDX) : NULL;
112 nD = zD ? strlen(zD)+1 : 0;
113 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
114
115 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
116
--- src/json_dir.c
+++ src/json_dir.c
@@ -83,33 +83,17 @@
83 "Checkin name [%s] is unresolved.",
84 zCI);
85 return NULL;
86 }
87 }
88 zDX = json_find_option_cstr("name",NULL,NULL);
 
 
 
 
 
 
 
 
 
89 if(!zDX && !g.isHTTP){
90 zDX = json_command_arg(g.json.dispatchDepth+1);
91 }
 
92 if(zDX && (!*zDX || (0==strcmp(zDX,"/")))){
93 zDX = NULL;
94 }
 
 
 
 
 
 
95 zD = zDX ? fossil_strdup(zDX) : NULL;
96 nD = zD ? strlen(zD)+1 : 0;
97 while( nD>1 && zD[nD-2]=='/' ){ zD[(--nD)-1] = 0; }
98
99 sqlite3_create_function(g.db, "pathelement", 2, SQLITE_UTF8, 0,
100
+7 -16
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -232,25 +232,11 @@
232232
if( !g.perm.RdWiki && !g.perm.Read ){
233233
json_set_err(FSL_JSON_E_DENIED,
234234
"Requires 'o' or 'j' access.");
235235
return NULL;
236236
}
237
- zPageName = json_find_option_cstr("name",NULL,"n")
238
- /* Damn... fossil automatically sets name to the PATH
239
- part after /json, so we need a workaround down here....
240
- */
241
- ;
242
- if( zPageName && (NULL != strstr(zPageName, "/"))){
243
- /* Assume that we picked up a path remnant. */
244
- zPageName = NULL;
245
- }
246
- if( !zPageName && cson_value_is_string(g.json.reqPayload.v) ){
247
- zPageName = cson_string_cstr(cson_value_get_string(g.json.reqPayload.v));
248
- }
249
- if(!zPageName){
250
- zPageName = json_command_arg(g.json.dispatchDepth+1);
251
- }
237
+ zPageName = json_find_option_cstr2("name",NULL,"n",g.json.dispatchDepth+1);
252238
253239
zSymName = json_find_option_cstr("uuid",NULL,"u");
254240
255241
if((!zPageName||!*zPageName) && (!zSymName || !*zSymName)){
256242
json_set_err(FSL_JSON_E_MISSING_ARGS,
@@ -336,10 +322,15 @@
336322
json_set_err( FSL_JSON_E_MISSING_ARGS,
337323
"'name' parameter is missing.");
338324
return NULL;
339325
}
340326
zPageName = cson_string_cstr(cson_value_get_string(nameV));
327
+ if(!zPageName || !*zPageName){
328
+ json_set_err(FSL_JSON_E_INVALID_ARGS,
329
+ "'name' parameter must be a non-empty string.");
330
+ return NULL;
331
+ }
341332
rid = db_int(0,
342333
"SELECT x.rid FROM tag t, tagxref x"
343334
" WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
344335
" ORDER BY x.mtime DESC LIMIT 1",
345336
zPageName
@@ -370,11 +361,11 @@
370361
}
371362
}
372363
if( !cson_value_is_string(nameV)
373364
|| !cson_value_is_string(contentV)){
374365
json_set_err(FSL_JSON_E_INVALID_ARGS,
375
- "'name' and 'content' parameters must be strings.");
366
+ "'content' parameter must be a string.");
376367
goto error;
377368
}
378369
jstr = cson_value_get_string(contentV);
379370
contentLen = (int)cson_string_length_bytes(jstr);
380371
if(contentLen){
381372
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -232,25 +232,11 @@
232 if( !g.perm.RdWiki && !g.perm.Read ){
233 json_set_err(FSL_JSON_E_DENIED,
234 "Requires 'o' or 'j' access.");
235 return NULL;
236 }
237 zPageName = json_find_option_cstr("name",NULL,"n")
238 /* Damn... fossil automatically sets name to the PATH
239 part after /json, so we need a workaround down here....
240 */
241 ;
242 if( zPageName && (NULL != strstr(zPageName, "/"))){
243 /* Assume that we picked up a path remnant. */
244 zPageName = NULL;
245 }
246 if( !zPageName && cson_value_is_string(g.json.reqPayload.v) ){
247 zPageName = cson_string_cstr(cson_value_get_string(g.json.reqPayload.v));
248 }
249 if(!zPageName){
250 zPageName = json_command_arg(g.json.dispatchDepth+1);
251 }
252
253 zSymName = json_find_option_cstr("uuid",NULL,"u");
254
255 if((!zPageName||!*zPageName) && (!zSymName || !*zSymName)){
256 json_set_err(FSL_JSON_E_MISSING_ARGS,
@@ -336,10 +322,15 @@
336 json_set_err( FSL_JSON_E_MISSING_ARGS,
337 "'name' parameter is missing.");
338 return NULL;
339 }
340 zPageName = cson_string_cstr(cson_value_get_string(nameV));
 
 
 
 
 
341 rid = db_int(0,
342 "SELECT x.rid FROM tag t, tagxref x"
343 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
344 " ORDER BY x.mtime DESC LIMIT 1",
345 zPageName
@@ -370,11 +361,11 @@
370 }
371 }
372 if( !cson_value_is_string(nameV)
373 || !cson_value_is_string(contentV)){
374 json_set_err(FSL_JSON_E_INVALID_ARGS,
375 "'name' and 'content' parameters must be strings.");
376 goto error;
377 }
378 jstr = cson_value_get_string(contentV);
379 contentLen = (int)cson_string_length_bytes(jstr);
380 if(contentLen){
381
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -232,25 +232,11 @@
232 if( !g.perm.RdWiki && !g.perm.Read ){
233 json_set_err(FSL_JSON_E_DENIED,
234 "Requires 'o' or 'j' access.");
235 return NULL;
236 }
237 zPageName = json_find_option_cstr2("name",NULL,"n",g.json.dispatchDepth+1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
239 zSymName = json_find_option_cstr("uuid",NULL,"u");
240
241 if((!zPageName||!*zPageName) && (!zSymName || !*zSymName)){
242 json_set_err(FSL_JSON_E_MISSING_ARGS,
@@ -336,10 +322,15 @@
322 json_set_err( FSL_JSON_E_MISSING_ARGS,
323 "'name' parameter is missing.");
324 return NULL;
325 }
326 zPageName = cson_string_cstr(cson_value_get_string(nameV));
327 if(!zPageName || !*zPageName){
328 json_set_err(FSL_JSON_E_INVALID_ARGS,
329 "'name' parameter must be a non-empty string.");
330 return NULL;
331 }
332 rid = db_int(0,
333 "SELECT x.rid FROM tag t, tagxref x"
334 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
335 " ORDER BY x.mtime DESC LIMIT 1",
336 zPageName
@@ -370,11 +361,11 @@
361 }
362 }
363 if( !cson_value_is_string(nameV)
364 || !cson_value_is_string(contentV)){
365 json_set_err(FSL_JSON_E_INVALID_ARGS,
366 "'content' parameter must be a string.");
367 goto error;
368 }
369 jstr = cson_value_get_string(contentV);
370 contentLen = (int)cson_string_length_bytes(jstr);
371 if(contentLen){
372

Keyboard Shortcuts

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