Fossil SCM
Remove the write-perms check from the /ajax/preview-text route so that folks without checkin permissions can use /chat. Problem reported in [forum:ed4a762b3a557898|forum post ed4a762b3a557898]. Some code-adjacent end-of-line whitespace cleanups.
Commit
0c6e669a7b0eacb2157464e7795d4bf08bb491672ab157d970fe99ca6962d5e4
Parent
70cae0a964299bb…
4 files changed
+11
-2
+1
-1
+2
-2
+1
-1
+11
-2
| --- src/ajax.c | ||
| +++ src/ajax.c | ||
| @@ -392,11 +392,20 @@ | ||
| 392 | 392 | const char * zName = P("name"); |
| 393 | 393 | AjaxRoute routeName = {0,0,0,0}; |
| 394 | 394 | const AjaxRoute * pRoute = 0; |
| 395 | 395 | const AjaxRoute routes[] = { |
| 396 | 396 | /* Keep these sorted by zName (for bsearch()) */ |
| 397 | - {"preview-text", ajax_route_preview_text, 1, 1} | |
| 397 | + {"preview-text", ajax_route_preview_text, 0, 1 | |
| 398 | + /* Note that this does not require write permissions in the repo. | |
| 399 | + ** It should arguably require write permissions but doing means | |
| 400 | + ** that /chat does not work without checkin permissions: | |
| 401 | + ** | |
| 402 | + ** https://fossil-scm.org/forum/forumpost/ed4a762b3a557898 | |
| 403 | + ** | |
| 404 | + ** This particular route is used by /fileedit and /chat, whereas | |
| 405 | + ** /wikiedit uses a simpler wiki-specific route. | |
| 406 | + */ } | |
| 398 | 407 | }; |
| 399 | 408 | |
| 400 | 409 | if(zName==0 || zName[0]==0){ |
| 401 | 410 | ajax_route_error(400,"Missing required [route] 'name' parameter."); |
| 402 | 411 | return; |
| @@ -409,7 +418,7 @@ | ||
| 409 | 418 | ajax_route_error(404,"Ajax route not found."); |
| 410 | 419 | return; |
| 411 | 420 | }else if(0==ajax_route_bootstrap(pRoute->bWriteMode, pRoute->bPost)){ |
| 412 | 421 | return; |
| 413 | 422 | } |
| 414 | - pRoute->xCallback(); | |
| 423 | + pRoute->xCallback(); | |
| 415 | 424 | } |
| 416 | 425 |
| --- src/ajax.c | |
| +++ src/ajax.c | |
| @@ -392,11 +392,20 @@ | |
| 392 | const char * zName = P("name"); |
| 393 | AjaxRoute routeName = {0,0,0,0}; |
| 394 | const AjaxRoute * pRoute = 0; |
| 395 | const AjaxRoute routes[] = { |
| 396 | /* Keep these sorted by zName (for bsearch()) */ |
| 397 | {"preview-text", ajax_route_preview_text, 1, 1} |
| 398 | }; |
| 399 | |
| 400 | if(zName==0 || zName[0]==0){ |
| 401 | ajax_route_error(400,"Missing required [route] 'name' parameter."); |
| 402 | return; |
| @@ -409,7 +418,7 @@ | |
| 409 | ajax_route_error(404,"Ajax route not found."); |
| 410 | return; |
| 411 | }else if(0==ajax_route_bootstrap(pRoute->bWriteMode, pRoute->bPost)){ |
| 412 | return; |
| 413 | } |
| 414 | pRoute->xCallback(); |
| 415 | } |
| 416 |
| --- src/ajax.c | |
| +++ src/ajax.c | |
| @@ -392,11 +392,20 @@ | |
| 392 | const char * zName = P("name"); |
| 393 | AjaxRoute routeName = {0,0,0,0}; |
| 394 | const AjaxRoute * pRoute = 0; |
| 395 | const AjaxRoute routes[] = { |
| 396 | /* Keep these sorted by zName (for bsearch()) */ |
| 397 | {"preview-text", ajax_route_preview_text, 0, 1 |
| 398 | /* Note that this does not require write permissions in the repo. |
| 399 | ** It should arguably require write permissions but doing means |
| 400 | ** that /chat does not work without checkin permissions: |
| 401 | ** |
| 402 | ** https://fossil-scm.org/forum/forumpost/ed4a762b3a557898 |
| 403 | ** |
| 404 | ** This particular route is used by /fileedit and /chat, whereas |
| 405 | ** /wikiedit uses a simpler wiki-specific route. |
| 406 | */ } |
| 407 | }; |
| 408 | |
| 409 | if(zName==0 || zName[0]==0){ |
| 410 | ajax_route_error(400,"Missing required [route] 'name' parameter."); |
| 411 | return; |
| @@ -409,7 +418,7 @@ | |
| 418 | ajax_route_error(404,"Ajax route not found."); |
| 419 | return; |
| 420 | }else if(0==ajax_route_bootstrap(pRoute->bWriteMode, pRoute->bPost)){ |
| 421 | return; |
| 422 | } |
| 423 | pRoute->xCallback(); |
| 424 | } |
| 425 |
+1
-1
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -1965,11 +1965,11 @@ | ||
| 1965 | 1965 | }); |
| 1966 | 1966 | return false; |
| 1967 | 1967 | }; |
| 1968 | 1968 | btnPreview.addEventListener('click', submit, false); |
| 1969 | 1969 | })()/*message preview setup*/; |
| 1970 | - | |
| 1970 | + | |
| 1971 | 1971 | /** Callback for poll() to inject new content into the page. jx == |
| 1972 | 1972 | the response from /chat-poll. If atEnd is true, the message is |
| 1973 | 1973 | appended to the end of the chat list (for loading older |
| 1974 | 1974 | messages), else the beginning (the default). */ |
| 1975 | 1975 | const newcontent = function f(jx,atEnd){ |
| 1976 | 1976 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1965,11 +1965,11 @@ | |
| 1965 | }); |
| 1966 | return false; |
| 1967 | }; |
| 1968 | btnPreview.addEventListener('click', submit, false); |
| 1969 | })()/*message preview setup*/; |
| 1970 | |
| 1971 | /** Callback for poll() to inject new content into the page. jx == |
| 1972 | the response from /chat-poll. If atEnd is true, the message is |
| 1973 | appended to the end of the chat list (for loading older |
| 1974 | messages), else the beginning (the default). */ |
| 1975 | const newcontent = function f(jx,atEnd){ |
| 1976 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1965,11 +1965,11 @@ | |
| 1965 | }); |
| 1966 | return false; |
| 1967 | }; |
| 1968 | btnPreview.addEventListener('click', submit, false); |
| 1969 | })()/*message preview setup*/; |
| 1970 | |
| 1971 | /** Callback for poll() to inject new content into the page. jx == |
| 1972 | the response from /chat-poll. If atEnd is true, the message is |
| 1973 | appended to the end of the chat list (for loading older |
| 1974 | messages), else the beginning (the default). */ |
| 1975 | const newcontent = function f(jx,atEnd){ |
| 1976 |
+2
-2
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -570,11 +570,11 @@ | ||
| 570 | 570 | D.attr(opt, 'selected', true); |
| 571 | 571 | } |
| 572 | 572 | }); |
| 573 | 573 | } |
| 574 | 574 | }/*P.stashWidget*/; |
| 575 | - | |
| 575 | + | |
| 576 | 576 | /** |
| 577 | 577 | Internal workaround to select the current preview mode |
| 578 | 578 | and fire a change event if the value actually changes |
| 579 | 579 | or if forceEvent is truthy. |
| 580 | 580 | */ |
| @@ -1161,11 +1161,11 @@ | ||
| 1161 | 1161 | if('string'===typeof c) D.parseHtml(target,c); |
| 1162 | 1162 | if(F.pikchr){ |
| 1163 | 1163 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1164 | 1164 | } |
| 1165 | 1165 | }; |
| 1166 | - | |
| 1166 | + | |
| 1167 | 1167 | /** |
| 1168 | 1168 | Callback for use with F.connectPagePreviewers() |
| 1169 | 1169 | */ |
| 1170 | 1170 | P._postPreview = function(content,callback){ |
| 1171 | 1171 | if(!affirmHasFile()) return this; |
| 1172 | 1172 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -570,11 +570,11 @@ | |
| 570 | D.attr(opt, 'selected', true); |
| 571 | } |
| 572 | }); |
| 573 | } |
| 574 | }/*P.stashWidget*/; |
| 575 | |
| 576 | /** |
| 577 | Internal workaround to select the current preview mode |
| 578 | and fire a change event if the value actually changes |
| 579 | or if forceEvent is truthy. |
| 580 | */ |
| @@ -1161,11 +1161,11 @@ | |
| 1161 | if('string'===typeof c) D.parseHtml(target,c); |
| 1162 | if(F.pikchr){ |
| 1163 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1164 | } |
| 1165 | }; |
| 1166 | |
| 1167 | /** |
| 1168 | Callback for use with F.connectPagePreviewers() |
| 1169 | */ |
| 1170 | P._postPreview = function(content,callback){ |
| 1171 | if(!affirmHasFile()) return this; |
| 1172 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -570,11 +570,11 @@ | |
| 570 | D.attr(opt, 'selected', true); |
| 571 | } |
| 572 | }); |
| 573 | } |
| 574 | }/*P.stashWidget*/; |
| 575 | |
| 576 | /** |
| 577 | Internal workaround to select the current preview mode |
| 578 | and fire a change event if the value actually changes |
| 579 | or if forceEvent is truthy. |
| 580 | */ |
| @@ -1161,11 +1161,11 @@ | |
| 1161 | if('string'===typeof c) D.parseHtml(target,c); |
| 1162 | if(F.pikchr){ |
| 1163 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1164 | } |
| 1165 | }; |
| 1166 | |
| 1167 | /** |
| 1168 | Callback for use with F.connectPagePreviewers() |
| 1169 | */ |
| 1170 | P._postPreview = function(content,callback){ |
| 1171 | if(!affirmHasFile()) return this; |
| 1172 |
+1
-1
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -1461,11 +1461,11 @@ | ||
| 1461 | 1461 | if('string'===typeof c) D.parseHtml(target,c); |
| 1462 | 1462 | if(F.pikchr){ |
| 1463 | 1463 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1464 | 1464 | } |
| 1465 | 1465 | }; |
| 1466 | - | |
| 1466 | + | |
| 1467 | 1467 | /** |
| 1468 | 1468 | Callback for use with F.connectPagePreviewers() |
| 1469 | 1469 | */ |
| 1470 | 1470 | P._postPreview = function(content,callback){ |
| 1471 | 1471 | if(!affirmPageLoaded()) return this; |
| 1472 | 1472 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -1461,11 +1461,11 @@ | |
| 1461 | if('string'===typeof c) D.parseHtml(target,c); |
| 1462 | if(F.pikchr){ |
| 1463 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1464 | } |
| 1465 | }; |
| 1466 | |
| 1467 | /** |
| 1468 | Callback for use with F.connectPagePreviewers() |
| 1469 | */ |
| 1470 | P._postPreview = function(content,callback){ |
| 1471 | if(!affirmPageLoaded()) return this; |
| 1472 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -1461,11 +1461,11 @@ | |
| 1461 | if('string'===typeof c) D.parseHtml(target,c); |
| 1462 | if(F.pikchr){ |
| 1463 | F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr')); |
| 1464 | } |
| 1465 | }; |
| 1466 | |
| 1467 | /** |
| 1468 | Callback for use with F.connectPagePreviewers() |
| 1469 | */ |
| 1470 | P._postPreview = function(content,callback){ |
| 1471 | if(!affirmPageLoaded()) return this; |
| 1472 |