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.

stephan 2023-12-22 14:27 trunk
Commit 0c6e669a7b0eacb2157464e7795d4bf08bb491672ab157d970fe99ca6962d5e4
+11 -2
--- src/ajax.c
+++ src/ajax.c
@@ -392,11 +392,20 @@
392392
const char * zName = P("name");
393393
AjaxRoute routeName = {0,0,0,0};
394394
const AjaxRoute * pRoute = 0;
395395
const AjaxRoute routes[] = {
396396
/* 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
+ */ }
398407
};
399408
400409
if(zName==0 || zName[0]==0){
401410
ajax_route_error(400,"Missing required [route] 'name' parameter.");
402411
return;
@@ -409,7 +418,7 @@
409418
ajax_route_error(404,"Ajax route not found.");
410419
return;
411420
}else if(0==ajax_route_bootstrap(pRoute->bWriteMode, pRoute->bPost)){
412421
return;
413422
}
414
- pRoute->xCallback();
423
+ pRoute->xCallback();
415424
}
416425
--- 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
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1965,11 +1965,11 @@
19651965
});
19661966
return false;
19671967
};
19681968
btnPreview.addEventListener('click', submit, false);
19691969
})()/*message preview setup*/;
1970
-
1970
+
19711971
/** Callback for poll() to inject new content into the page. jx ==
19721972
the response from /chat-poll. If atEnd is true, the message is
19731973
appended to the end of the chat list (for loading older
19741974
messages), else the beginning (the default). */
19751975
const newcontent = function f(jx,atEnd){
19761976
--- 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
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -570,11 +570,11 @@
570570
D.attr(opt, 'selected', true);
571571
}
572572
});
573573
}
574574
}/*P.stashWidget*/;
575
-
575
+
576576
/**
577577
Internal workaround to select the current preview mode
578578
and fire a change event if the value actually changes
579579
or if forceEvent is truthy.
580580
*/
@@ -1161,11 +1161,11 @@
11611161
if('string'===typeof c) D.parseHtml(target,c);
11621162
if(F.pikchr){
11631163
F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr'));
11641164
}
11651165
};
1166
-
1166
+
11671167
/**
11681168
Callback for use with F.connectPagePreviewers()
11691169
*/
11701170
P._postPreview = function(content,callback){
11711171
if(!affirmHasFile()) return this;
11721172
--- 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
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -1461,11 +1461,11 @@
14611461
if('string'===typeof c) D.parseHtml(target,c);
14621462
if(F.pikchr){
14631463
F.pikchr.addSrcView(target.querySelectorAll('svg.pikchr'));
14641464
}
14651465
};
1466
-
1466
+
14671467
/**
14681468
Callback for use with F.connectPagePreviewers()
14691469
*/
14701470
P._postPreview = function(content,callback){
14711471
if(!affirmPageLoaded()) return this;
14721472
--- 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

Keyboard Shortcuts

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