Fossil SCM
fixed /json/wiki/get to fail with a resource-not-found error if given the name of an unknown page.
Commit
ac8c1ad4bbbf31d87b3d8dfe2035e600993d20a6
Parent
6c835ea8c7c615f…
1 file changed
+3
-1
+3
-1
| --- src/json_wiki.c | ||
| +++ src/json_wiki.c | ||
| @@ -59,11 +59,11 @@ | ||
| 59 | 59 | ** parsing is performed, if it is 0 then the content is not returned |
| 60 | 60 | ** in the response. If contentFormat is 0 then the contentSize reflects |
| 61 | 61 | ** the number of bytes, not characters, stored in the page. |
| 62 | 62 | ** |
| 63 | 63 | ** The returned value, if not NULL, is-a JSON Object owned by the |
| 64 | -** caller. | |
| 64 | +** caller. If it returns NULL then it may set g.json's error state. | |
| 65 | 65 | */ |
| 66 | 66 | cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){ |
| 67 | 67 | int rid; |
| 68 | 68 | Manifest *pWiki = 0; |
| 69 | 69 | char const * zBody = NULL; |
| @@ -77,10 +77,12 @@ | ||
| 77 | 77 | " ORDER BY x.mtime DESC LIMIT 1", |
| 78 | 78 | zPageName |
| 79 | 79 | ); |
| 80 | 80 | if( (SQLITE_ROW != db_step(&q)) ){ |
| 81 | 81 | db_finalize(&q); |
| 82 | + json_set_err( FSL_JSON_E_RESOURCE_NOT_FOUND, "Wiki page not found: %s", | |
| 83 | + zPageName ); | |
| 82 | 84 | return NULL; |
| 83 | 85 | } |
| 84 | 86 | rid = db_column_int(&q,0); |
| 85 | 87 | zUuid = db_column_malloc(&q,1); |
| 86 | 88 | db_finalize(&q); |
| 87 | 89 |
| --- src/json_wiki.c | |
| +++ src/json_wiki.c | |
| @@ -59,11 +59,11 @@ | |
| 59 | ** parsing is performed, if it is 0 then the content is not returned |
| 60 | ** in the response. If contentFormat is 0 then the contentSize reflects |
| 61 | ** the number of bytes, not characters, stored in the page. |
| 62 | ** |
| 63 | ** The returned value, if not NULL, is-a JSON Object owned by the |
| 64 | ** caller. |
| 65 | */ |
| 66 | cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){ |
| 67 | int rid; |
| 68 | Manifest *pWiki = 0; |
| 69 | char const * zBody = NULL; |
| @@ -77,10 +77,12 @@ | |
| 77 | " ORDER BY x.mtime DESC LIMIT 1", |
| 78 | zPageName |
| 79 | ); |
| 80 | if( (SQLITE_ROW != db_step(&q)) ){ |
| 81 | db_finalize(&q); |
| 82 | return NULL; |
| 83 | } |
| 84 | rid = db_column_int(&q,0); |
| 85 | zUuid = db_column_malloc(&q,1); |
| 86 | db_finalize(&q); |
| 87 |
| --- src/json_wiki.c | |
| +++ src/json_wiki.c | |
| @@ -59,11 +59,11 @@ | |
| 59 | ** parsing is performed, if it is 0 then the content is not returned |
| 60 | ** in the response. If contentFormat is 0 then the contentSize reflects |
| 61 | ** the number of bytes, not characters, stored in the page. |
| 62 | ** |
| 63 | ** The returned value, if not NULL, is-a JSON Object owned by the |
| 64 | ** caller. If it returns NULL then it may set g.json's error state. |
| 65 | */ |
| 66 | cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){ |
| 67 | int rid; |
| 68 | Manifest *pWiki = 0; |
| 69 | char const * zBody = NULL; |
| @@ -77,10 +77,12 @@ | |
| 77 | " ORDER BY x.mtime DESC LIMIT 1", |
| 78 | zPageName |
| 79 | ); |
| 80 | if( (SQLITE_ROW != db_step(&q)) ){ |
| 81 | db_finalize(&q); |
| 82 | json_set_err( FSL_JSON_E_RESOURCE_NOT_FOUND, "Wiki page not found: %s", |
| 83 | zPageName ); |
| 84 | return NULL; |
| 85 | } |
| 86 | rid = db_column_int(&q,0); |
| 87 | zUuid = db_column_malloc(&q,1); |
| 88 | db_finalize(&q); |
| 89 |