Fossil SCM

Clarify the origin of JS in the generated HTML.

drh 2020-09-18 03:28 trunk
Commit 6854244949f334722f97d3d8a60ee8adb5c26e09154d5d1437d6331f46964271
+2 -3
--- src/ajax.c
+++ src/ajax.c
@@ -46,12 +46,11 @@
4646
** Requires that builtin_emit_script_fossil_bootstrap() has already been
4747
** called in order to initialize the window.fossil.page object.
4848
*/
4949
void ajax_emit_js_preview_modes(int addScriptTag){
5050
if(addScriptTag){
51
- style_emit_script_tag(0,0);
52
- CX("\n");
51
+ style_script_begin(__FILE__,__LINE__);
5352
}
5453
CX("fossil.page.previewModes={"
5554
"guess: %d, %d: 'guess', wiki: %d, %d: 'wiki',"
5655
"htmlIframe: %d, %d: 'htmlIframe', "
5756
"htmlInline: %d, %d: 'htmlInline', "
@@ -61,11 +60,11 @@
6160
AJAX_RENDER_WIKI, AJAX_RENDER_WIKI,
6261
AJAX_RENDER_HTML_IFRAME, AJAX_RENDER_HTML_IFRAME,
6362
AJAX_RENDER_HTML_INLINE, AJAX_RENDER_HTML_INLINE,
6463
AJAX_RENDER_PLAIN_TEXT, AJAX_RENDER_PLAIN_TEXT);
6564
if(addScriptTag){
66
- style_emit_script_tag(1,0);
65
+ style_script_end();
6766
}
6867
}
6968
7069
/*
7170
** Returns a value from the ajax_render_modes enum, based on the
7271
--- src/ajax.c
+++ src/ajax.c
@@ -46,12 +46,11 @@
46 ** Requires that builtin_emit_script_fossil_bootstrap() has already been
47 ** called in order to initialize the window.fossil.page object.
48 */
49 void ajax_emit_js_preview_modes(int addScriptTag){
50 if(addScriptTag){
51 style_emit_script_tag(0,0);
52 CX("\n");
53 }
54 CX("fossil.page.previewModes={"
55 "guess: %d, %d: 'guess', wiki: %d, %d: 'wiki',"
56 "htmlIframe: %d, %d: 'htmlIframe', "
57 "htmlInline: %d, %d: 'htmlInline', "
@@ -61,11 +60,11 @@
61 AJAX_RENDER_WIKI, AJAX_RENDER_WIKI,
62 AJAX_RENDER_HTML_IFRAME, AJAX_RENDER_HTML_IFRAME,
63 AJAX_RENDER_HTML_INLINE, AJAX_RENDER_HTML_INLINE,
64 AJAX_RENDER_PLAIN_TEXT, AJAX_RENDER_PLAIN_TEXT);
65 if(addScriptTag){
66 style_emit_script_tag(1,0);
67 }
68 }
69
70 /*
71 ** Returns a value from the ajax_render_modes enum, based on the
72
--- src/ajax.c
+++ src/ajax.c
@@ -46,12 +46,11 @@
46 ** Requires that builtin_emit_script_fossil_bootstrap() has already been
47 ** called in order to initialize the window.fossil.page object.
48 */
49 void ajax_emit_js_preview_modes(int addScriptTag){
50 if(addScriptTag){
51 style_script_begin(__FILE__,__LINE__);
 
52 }
53 CX("fossil.page.previewModes={"
54 "guess: %d, %d: 'guess', wiki: %d, %d: 'wiki',"
55 "htmlIframe: %d, %d: 'htmlIframe', "
56 "htmlInline: %d, %d: 'htmlInline', "
@@ -61,11 +60,11 @@
60 AJAX_RENDER_WIKI, AJAX_RENDER_WIKI,
61 AJAX_RENDER_HTML_IFRAME, AJAX_RENDER_HTML_IFRAME,
62 AJAX_RENDER_HTML_INLINE, AJAX_RENDER_HTML_INLINE,
63 AJAX_RENDER_PLAIN_TEXT, AJAX_RENDER_PLAIN_TEXT);
64 if(addScriptTag){
65 style_script_end();
66 }
67 }
68
69 /*
70 ** Returns a value from the ajax_render_modes enum, based on the
71
+3 -3
--- src/builtin.c
+++ src/builtin.c
@@ -316,11 +316,11 @@
316316
switch( builtin.eDelivery ){
317317
case JS_INLINE: {
318318
CX("<script nonce='%h'>\n",style_nonce());
319319
do{
320320
int i = builtin.aReq[builtin.nSent++];
321
- CX("/* %s */\n", aBuiltinFiles[i].zName);
321
+ CX("/* %s %.60c*/\n", aBuiltinFiles[i].zName, '*');
322322
cgi_append_content((const char*)aBuiltinFiles[i].pData,
323323
aBuiltinFiles[i].nByte);
324324
}while( builtin.nSent<builtin.nReq );
325325
CX("</script>\n");
326326
break;
@@ -592,11 +592,11 @@
592592
if(0==once++){
593593
char * zName;
594594
/* Set up the generic/app-agnostic parts of window.fossil
595595
** which require C-level state... */
596596
if(addScriptTag!=0){
597
- style_emit_script_tag(0,0);
597
+ style_script_begin(__FILE__,__LINE__);
598598
}
599599
CX("(function(){\n");
600600
CX(/*MSIE NodeList.forEach polyfill, courtesy of Mozilla:
601601
https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
602602
*/
@@ -655,11 +655,11 @@
655655
CX("window.fossil.page = {"
656656
"name:\"%T\""
657657
"};\n", g.zPath);
658658
CX("})();\n");
659659
if(addScriptTag!=0){
660
- style_emit_script_tag(1,0);
660
+ style_script_end();
661661
}
662662
/* The remaining window.fossil bootstrap code is not dependent on
663663
** C-runtime state... */
664664
builtin_request_js("fossil.bootstrap.js");
665665
}
666666
--- src/builtin.c
+++ src/builtin.c
@@ -316,11 +316,11 @@
316 switch( builtin.eDelivery ){
317 case JS_INLINE: {
318 CX("<script nonce='%h'>\n",style_nonce());
319 do{
320 int i = builtin.aReq[builtin.nSent++];
321 CX("/* %s */\n", aBuiltinFiles[i].zName);
322 cgi_append_content((const char*)aBuiltinFiles[i].pData,
323 aBuiltinFiles[i].nByte);
324 }while( builtin.nSent<builtin.nReq );
325 CX("</script>\n");
326 break;
@@ -592,11 +592,11 @@
592 if(0==once++){
593 char * zName;
594 /* Set up the generic/app-agnostic parts of window.fossil
595 ** which require C-level state... */
596 if(addScriptTag!=0){
597 style_emit_script_tag(0,0);
598 }
599 CX("(function(){\n");
600 CX(/*MSIE NodeList.forEach polyfill, courtesy of Mozilla:
601 https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
602 */
@@ -655,11 +655,11 @@
655 CX("window.fossil.page = {"
656 "name:\"%T\""
657 "};\n", g.zPath);
658 CX("})();\n");
659 if(addScriptTag!=0){
660 style_emit_script_tag(1,0);
661 }
662 /* The remaining window.fossil bootstrap code is not dependent on
663 ** C-runtime state... */
664 builtin_request_js("fossil.bootstrap.js");
665 }
666
--- src/builtin.c
+++ src/builtin.c
@@ -316,11 +316,11 @@
316 switch( builtin.eDelivery ){
317 case JS_INLINE: {
318 CX("<script nonce='%h'>\n",style_nonce());
319 do{
320 int i = builtin.aReq[builtin.nSent++];
321 CX("/* %s %.60c*/\n", aBuiltinFiles[i].zName, '*');
322 cgi_append_content((const char*)aBuiltinFiles[i].pData,
323 aBuiltinFiles[i].nByte);
324 }while( builtin.nSent<builtin.nReq );
325 CX("</script>\n");
326 break;
@@ -592,11 +592,11 @@
592 if(0==once++){
593 char * zName;
594 /* Set up the generic/app-agnostic parts of window.fossil
595 ** which require C-level state... */
596 if(addScriptTag!=0){
597 style_script_begin(__FILE__,__LINE__);
598 }
599 CX("(function(){\n");
600 CX(/*MSIE NodeList.forEach polyfill, courtesy of Mozilla:
601 https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
602 */
@@ -655,11 +655,11 @@
655 CX("window.fossil.page = {"
656 "name:\"%T\""
657 "};\n", g.zPath);
658 CX("})();\n");
659 if(addScriptTag!=0){
660 style_script_end();
661 }
662 /* The remaining window.fossil bootstrap code is not dependent on
663 ** C-runtime state... */
664 builtin_request_js("fossil.bootstrap.js");
665 }
666
+1 -1
--- src/captcha.c
+++ src/captcha.c
@@ -562,11 +562,11 @@
562562
*/
563563
void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
564564
if( zMsg==0 ) zMsg = "Speak the text";
565565
@ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \
566566
@ id="speakthetext">
567
- @ <script nonce="%h(style_nonce())">
567
+ @ <script nonce="%h(style_nonce())">/* captcha_speakit_button() */
568568
@ document.getElementById("speakthetext").onclick = function(){
569569
@ var audio = window.fossilAudioCaptcha \
570570
@ || new Audio("%R/captcha-audio/%u(uSeed)");
571571
@ window.fossilAudioCaptcha = audio;
572572
@ audio.currentTime = 0;
573573
--- src/captcha.c
+++ src/captcha.c
@@ -562,11 +562,11 @@
562 */
563 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
564 if( zMsg==0 ) zMsg = "Speak the text";
565 @ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \
566 @ id="speakthetext">
567 @ <script nonce="%h(style_nonce())">
568 @ document.getElementById("speakthetext").onclick = function(){
569 @ var audio = window.fossilAudioCaptcha \
570 @ || new Audio("%R/captcha-audio/%u(uSeed)");
571 @ window.fossilAudioCaptcha = audio;
572 @ audio.currentTime = 0;
573
--- src/captcha.c
+++ src/captcha.c
@@ -562,11 +562,11 @@
562 */
563 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
564 if( zMsg==0 ) zMsg = "Speak the text";
565 @ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \
566 @ id="speakthetext">
567 @ <script nonce="%h(style_nonce())">/* captcha_speakit_button() */
568 @ document.getElementById("speakthetext").onclick = function(){
569 @ var audio = window.fossilAudioCaptcha \
570 @ || new Audio("%R/captcha-audio/%u(uSeed)");
571 @ window.fossilAudioCaptcha = audio;
572 @ audio.currentTime = 0;
573
+2 -2
--- src/doc.c
+++ src/doc.c
@@ -408,15 +408,15 @@
408408
void document_emit_js(void){
409409
if(!builtin_bundle_all_fossil_js_apis()){
410410
builtin_emit_fossil_js_apis("dom", "copybutton",
411411
"pikchr", 0);
412412
}
413
- style_emit_script_tag(0,0);
413
+ style_script_begin(__FILE__,__LINE__);
414414
CX("window.addEventListener('load', "
415415
"()=>window.fossil.pikchr.addSrcView(), "
416416
"false);\n");
417
- style_emit_script_tag(1,0);
417
+ style_script_end();
418418
}
419419
420420
/*
421421
** Guess the mime-type of a document based on its name.
422422
*/
423423
--- src/doc.c
+++ src/doc.c
@@ -408,15 +408,15 @@
408 void document_emit_js(void){
409 if(!builtin_bundle_all_fossil_js_apis()){
410 builtin_emit_fossil_js_apis("dom", "copybutton",
411 "pikchr", 0);
412 }
413 style_emit_script_tag(0,0);
414 CX("window.addEventListener('load', "
415 "()=>window.fossil.pikchr.addSrcView(), "
416 "false);\n");
417 style_emit_script_tag(1,0);
418 }
419
420 /*
421 ** Guess the mime-type of a document based on its name.
422 */
423
--- src/doc.c
+++ src/doc.c
@@ -408,15 +408,15 @@
408 void document_emit_js(void){
409 if(!builtin_bundle_all_fossil_js_apis()){
410 builtin_emit_fossil_js_apis("dom", "copybutton",
411 "pikchr", 0);
412 }
413 style_script_begin(__FILE__,__LINE__);
414 CX("window.addEventListener('load', "
415 "()=>window.fossil.pikchr.addSrcView(), "
416 "false);\n");
417 style_script_end();
418 }
419
420 /*
421 ** Guess the mime-type of a document based on its name.
422 */
423
+4 -4
--- src/fileedit.c
+++ src/fileedit.c
@@ -1666,13 +1666,13 @@
16661666
** don't want inadvertently being used by other pages. We don't
16671667
** have a common, page-specific container we can filter our CSS
16681668
** selectors, but we do have the BODY, which we can decorate with
16691669
** whatever CSS we wish...
16701670
*/
1671
- style_emit_script_tag(0,0);
1671
+ style_script_begin(__FILE__,__LINE__);
16721672
CX("document.body.classList.add('fileedit');\n");
1673
- style_emit_script_tag(1,0);
1673
+ style_script_end();
16741674
16751675
/* Status bar */
16761676
CX("<div id='fossil-status-bar' "
16771677
"title='Status message area. Double-click to clear them.'>"
16781678
"Status messages will go here.</div>\n"
@@ -2009,11 +2009,11 @@
20092009
{
20102010
/* Dynamically populate the editor, display any error in the err
20112011
** blob, and/or switch to tab #0, where the file selector
20122012
** lives. The extra C scopes here correspond to JS-level scopes,
20132013
** to improve grokability. */
2014
- style_emit_script_tag(0,0);
2014
+ style_script_begin(__FILE__,__LINE__);
20152015
CX("\n(function(){\n");
20162016
CX("try{\n");
20172017
{
20182018
char * zFirstLeafUuid = 0;
20192019
CX("fossil.config['fileedit-glob'] = ");
@@ -2058,12 +2058,12 @@
20582058
}
20592059
CX("}catch(e){"
20602060
"fossil.error(e); console.error('Exception:',e);"
20612061
"}\n");
20622062
CX("})();")/*anonymous function*/;
2063
- style_emit_script_tag(1,0);
2063
+ style_script_end();
20642064
}
20652065
blob_reset(&err);
20662066
CheckinMiniInfo_cleanup(&cimi);
20672067
db_end_transaction(0);
20682068
style_footer();
20692069
}
20702070
--- src/fileedit.c
+++ src/fileedit.c
@@ -1666,13 +1666,13 @@
1666 ** don't want inadvertently being used by other pages. We don't
1667 ** have a common, page-specific container we can filter our CSS
1668 ** selectors, but we do have the BODY, which we can decorate with
1669 ** whatever CSS we wish...
1670 */
1671 style_emit_script_tag(0,0);
1672 CX("document.body.classList.add('fileedit');\n");
1673 style_emit_script_tag(1,0);
1674
1675 /* Status bar */
1676 CX("<div id='fossil-status-bar' "
1677 "title='Status message area. Double-click to clear them.'>"
1678 "Status messages will go here.</div>\n"
@@ -2009,11 +2009,11 @@
2009 {
2010 /* Dynamically populate the editor, display any error in the err
2011 ** blob, and/or switch to tab #0, where the file selector
2012 ** lives. The extra C scopes here correspond to JS-level scopes,
2013 ** to improve grokability. */
2014 style_emit_script_tag(0,0);
2015 CX("\n(function(){\n");
2016 CX("try{\n");
2017 {
2018 char * zFirstLeafUuid = 0;
2019 CX("fossil.config['fileedit-glob'] = ");
@@ -2058,12 +2058,12 @@
2058 }
2059 CX("}catch(e){"
2060 "fossil.error(e); console.error('Exception:',e);"
2061 "}\n");
2062 CX("})();")/*anonymous function*/;
2063 style_emit_script_tag(1,0);
2064 }
2065 blob_reset(&err);
2066 CheckinMiniInfo_cleanup(&cimi);
2067 db_end_transaction(0);
2068 style_footer();
2069 }
2070
--- src/fileedit.c
+++ src/fileedit.c
@@ -1666,13 +1666,13 @@
1666 ** don't want inadvertently being used by other pages. We don't
1667 ** have a common, page-specific container we can filter our CSS
1668 ** selectors, but we do have the BODY, which we can decorate with
1669 ** whatever CSS we wish...
1670 */
1671 style_script_begin(__FILE__,__LINE__);
1672 CX("document.body.classList.add('fileedit');\n");
1673 style_script_end();
1674
1675 /* Status bar */
1676 CX("<div id='fossil-status-bar' "
1677 "title='Status message area. Double-click to clear them.'>"
1678 "Status messages will go here.</div>\n"
@@ -2009,11 +2009,11 @@
2009 {
2010 /* Dynamically populate the editor, display any error in the err
2011 ** blob, and/or switch to tab #0, where the file selector
2012 ** lives. The extra C scopes here correspond to JS-level scopes,
2013 ** to improve grokability. */
2014 style_script_begin(__FILE__,__LINE__);
2015 CX("\n(function(){\n");
2016 CX("try{\n");
2017 {
2018 char * zFirstLeafUuid = 0;
2019 CX("fossil.config['fileedit-glob'] = ");
@@ -2058,12 +2058,12 @@
2058 }
2059 CX("}catch(e){"
2060 "fossil.error(e); console.error('Exception:',e);"
2061 "}\n");
2062 CX("})();")/*anonymous function*/;
2063 style_script_end();
2064 }
2065 blob_reset(&err);
2066 CheckinMiniInfo_cleanup(&cimi);
2067 db_end_transaction(0);
2068 style_footer();
2069 }
2070
+1 -1
--- src/info.c
+++ src/info.c
@@ -2444,11 +2444,11 @@
24442444
}else if( renderAsHtml ){
24452445
@ <iframe src="%R/raw/%s(zUuid)"
24462446
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
24472447
@ sandbox="allow-same-origin" id="ifm1">
24482448
@ </iframe>
2449
- @ <script nonce="%h(style_nonce())">
2449
+ @ <script nonce="%h(style_nonce())">/* info.c:%d(__LINE__) */
24502450
@ document.getElementById("ifm1").addEventListener("load",
24512451
@ function(){
24522452
@ this.height=this.contentDocument.documentElement.scrollHeight + 75;
24532453
@ }
24542454
@ );
24552455
--- src/info.c
+++ src/info.c
@@ -2444,11 +2444,11 @@
2444 }else if( renderAsHtml ){
2445 @ <iframe src="%R/raw/%s(zUuid)"
2446 @ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
2447 @ sandbox="allow-same-origin" id="ifm1">
2448 @ </iframe>
2449 @ <script nonce="%h(style_nonce())">
2450 @ document.getElementById("ifm1").addEventListener("load",
2451 @ function(){
2452 @ this.height=this.contentDocument.documentElement.scrollHeight + 75;
2453 @ }
2454 @ );
2455
--- src/info.c
+++ src/info.c
@@ -2444,11 +2444,11 @@
2444 }else if( renderAsHtml ){
2445 @ <iframe src="%R/raw/%s(zUuid)"
2446 @ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
2447 @ sandbox="allow-same-origin" id="ifm1">
2448 @ </iframe>
2449 @ <script nonce="%h(style_nonce())">/* info.c:%d(__LINE__) */
2450 @ document.getElementById("ifm1").addEventListener("load",
2451 @ function(){
2452 @ this.height=this.contentDocument.documentElement.scrollHeight + 75;
2453 @ }
2454 @ );
2455
+19 -27
--- src/style.c
+++ src/style.c
@@ -714,11 +714,11 @@
714714
int nDelay = db_get_int("auto-hyperlink-delay",0);
715715
int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0);
716716
@ <script id='href-data' type='application/json'>\
717717
@ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
718718
}
719
- @ <script nonce="%h(style_nonce())">
719
+ @ <script nonce="%h(style_nonce())">/* style.c:%d(__LINE__) */
720720
@ function debugMsg(msg){
721721
@ var n = document.getElementById("debugMsg");
722722
@ if(n){n.textContent=msg;}
723723
@ }
724724
if( needHrefJs ){
@@ -1428,37 +1428,29 @@
14281428
va_end(vargs);
14291429
fossil_free(zLabelID);
14301430
}
14311431
14321432
/*
1433
-** If passed 0 as its first argument, it emits a script opener tag
1434
-** with this request's nonce. If passed non-0 it emits a script
1435
-** closing tag. Mnemonic for remembering the order in which to pass 0
1436
-** or 1 as the first argument to this function: 0 comes before 1.
1437
-**
1438
-** If passed 0 as its first argument and a non-NULL/non-empty zSrc,
1439
-** then it instead emits:
1440
-**
1441
-** <script src='%R/{{zSrc}}'></script>
1442
-**
1443
-** zSrc is always assumed to be a repository-relative path without
1444
-** a leading slash, and has %R/ prepended to it.
1445
-**
1446
-** Meaning that no follow-up call to pass a non-0 first argument
1447
-** to close the tag. zSrc is ignored if the first argument is not
1448
-** 0.
1433
+** Generate a <script> with an appropriate nonce.
1434
+**
1435
+** zOrigin and iLine are the source code filename and line number
1436
+** that generated this request.
1437
+*/
1438
+void style_script_begin(const char *zOrigin, int iLine){
1439
+ const char *z;
1440
+ for(z=zOrigin; z[0]!=0; z++){
1441
+ if( z[0]=='/' || z[0]=='\\' ){
1442
+ zOrigin = z+1;
1443
+ }
1444
+ }
1445
+ CX("<script nonce='%s'>/* %s:%d */\n", style_nonce(), zOrigin, iLine);
1446
+}
1447
+
1448
+/* Generate the closing </script> tag
14491449
*/
1450
-void style_emit_script_tag(int isCloser, const char * zSrc){
1451
- if(0==isCloser){
1452
- if(zSrc!=0 && zSrc[0]!=0){
1453
- CX("<script src='%R/%T'></script>\n", zSrc);
1454
- }else{
1455
- CX("<script nonce='%s'>", style_nonce());
1456
- }
1457
- }else{
1458
- CX("</script>\n");
1459
- }
1450
+void style_script_end(void){
1451
+ CX("</script>\n");
14601452
}
14611453
14621454
/*
14631455
** Emits a NOSCRIPT tag with an error message stating that JS is
14641456
** required for the current page. This "should" be called near the top
14651457
--- src/style.c
+++ src/style.c
@@ -714,11 +714,11 @@
714 int nDelay = db_get_int("auto-hyperlink-delay",0);
715 int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0);
716 @ <script id='href-data' type='application/json'>\
717 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
718 }
719 @ <script nonce="%h(style_nonce())">
720 @ function debugMsg(msg){
721 @ var n = document.getElementById("debugMsg");
722 @ if(n){n.textContent=msg;}
723 @ }
724 if( needHrefJs ){
@@ -1428,37 +1428,29 @@
1428 va_end(vargs);
1429 fossil_free(zLabelID);
1430 }
1431
1432 /*
1433 ** If passed 0 as its first argument, it emits a script opener tag
1434 ** with this request's nonce. If passed non-0 it emits a script
1435 ** closing tag. Mnemonic for remembering the order in which to pass 0
1436 ** or 1 as the first argument to this function: 0 comes before 1.
1437 **
1438 ** If passed 0 as its first argument and a non-NULL/non-empty zSrc,
1439 ** then it instead emits:
1440 **
1441 ** <script src='%R/{{zSrc}}'></script>
1442 **
1443 ** zSrc is always assumed to be a repository-relative path without
1444 ** a leading slash, and has %R/ prepended to it.
1445 **
1446 ** Meaning that no follow-up call to pass a non-0 first argument
1447 ** to close the tag. zSrc is ignored if the first argument is not
1448 ** 0.
1449 */
1450 void style_emit_script_tag(int isCloser, const char * zSrc){
1451 if(0==isCloser){
1452 if(zSrc!=0 && zSrc[0]!=0){
1453 CX("<script src='%R/%T'></script>\n", zSrc);
1454 }else{
1455 CX("<script nonce='%s'>", style_nonce());
1456 }
1457 }else{
1458 CX("</script>\n");
1459 }
1460 }
1461
1462 /*
1463 ** Emits a NOSCRIPT tag with an error message stating that JS is
1464 ** required for the current page. This "should" be called near the top
1465
--- src/style.c
+++ src/style.c
@@ -714,11 +714,11 @@
714 int nDelay = db_get_int("auto-hyperlink-delay",0);
715 int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0);
716 @ <script id='href-data' type='application/json'>\
717 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
718 }
719 @ <script nonce="%h(style_nonce())">/* style.c:%d(__LINE__) */
720 @ function debugMsg(msg){
721 @ var n = document.getElementById("debugMsg");
722 @ if(n){n.textContent=msg;}
723 @ }
724 if( needHrefJs ){
@@ -1428,37 +1428,29 @@
1428 va_end(vargs);
1429 fossil_free(zLabelID);
1430 }
1431
1432 /*
1433 ** Generate a <script> with an appropriate nonce.
1434 **
1435 ** zOrigin and iLine are the source code filename and line number
1436 ** that generated this request.
1437 */
1438 void style_script_begin(const char *zOrigin, int iLine){
1439 const char *z;
1440 for(z=zOrigin; z[0]!=0; z++){
1441 if( z[0]=='/' || z[0]=='\\' ){
1442 zOrigin = z+1;
1443 }
1444 }
1445 CX("<script nonce='%s'>/* %s:%d */\n", style_nonce(), zOrigin, iLine);
1446 }
1447
1448 /* Generate the closing </script> tag
1449 */
1450 void style_script_end(void){
1451 CX("</script>\n");
 
 
 
 
 
 
 
 
1452 }
1453
1454 /*
1455 ** Emits a NOSCRIPT tag with an error message stating that JS is
1456 ** required for the current page. This "should" be called near the top
1457
+2 -2
--- src/wiki.c
+++ src/wiki.c
@@ -1291,11 +1291,11 @@
12911291
}
12921292
builtin_request_js("sbsdiff.js");
12931293
builtin_request_js("fossil.page.wikiedit.js");
12941294
builtin_fulfill_js_requests();
12951295
/* Dynamically populate the editor... */
1296
- style_emit_script_tag(0,0);
1296
+ style_script_begin(__FILE__,__LINE__);
12971297
{
12981298
/* Render the current page list to save us an XHR request
12991299
during page initialization. This must be OUTSIDE of
13001300
an onPageLoad() handler or else it does not get applied
13011301
until after the wiki list widget is initialized. Similarly,
@@ -1330,11 +1330,11 @@
13301330
}
13311331
CX("}catch(e){"
13321332
"fossil.error(e); console.error('Exception:',e);"
13331333
"}\n");
13341334
CX("});\n"/*fossil.onPageLoad()*/);
1335
- style_emit_script_tag(1,0);
1335
+ style_script_end();
13361336
style_footer();
13371337
}
13381338
13391339
/*
13401340
** WEBPAGE: wikinew
13411341
--- src/wiki.c
+++ src/wiki.c
@@ -1291,11 +1291,11 @@
1291 }
1292 builtin_request_js("sbsdiff.js");
1293 builtin_request_js("fossil.page.wikiedit.js");
1294 builtin_fulfill_js_requests();
1295 /* Dynamically populate the editor... */
1296 style_emit_script_tag(0,0);
1297 {
1298 /* Render the current page list to save us an XHR request
1299 during page initialization. This must be OUTSIDE of
1300 an onPageLoad() handler or else it does not get applied
1301 until after the wiki list widget is initialized. Similarly,
@@ -1330,11 +1330,11 @@
1330 }
1331 CX("}catch(e){"
1332 "fossil.error(e); console.error('Exception:',e);"
1333 "}\n");
1334 CX("});\n"/*fossil.onPageLoad()*/);
1335 style_emit_script_tag(1,0);
1336 style_footer();
1337 }
1338
1339 /*
1340 ** WEBPAGE: wikinew
1341
--- src/wiki.c
+++ src/wiki.c
@@ -1291,11 +1291,11 @@
1291 }
1292 builtin_request_js("sbsdiff.js");
1293 builtin_request_js("fossil.page.wikiedit.js");
1294 builtin_fulfill_js_requests();
1295 /* Dynamically populate the editor... */
1296 style_script_begin(__FILE__,__LINE__);
1297 {
1298 /* Render the current page list to save us an XHR request
1299 during page initialization. This must be OUTSIDE of
1300 an onPageLoad() handler or else it does not get applied
1301 until after the wiki list widget is initialized. Similarly,
@@ -1330,11 +1330,11 @@
1330 }
1331 CX("}catch(e){"
1332 "fossil.error(e); console.error('Exception:',e);"
1333 "}\n");
1334 CX("});\n"/*fossil.onPageLoad()*/);
1335 style_script_end();
1336 style_footer();
1337 }
1338
1339 /*
1340 ** WEBPAGE: wikinew
1341

Keyboard Shortcuts

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