Fossil SCM
Clarify the origin of JS in the generated HTML.
Commit
6854244949f334722f97d3d8a60ee8adb5c26e09154d5d1437d6331f46964271
Parent
39b2081e6eea8ca…
8 files changed
+2
-3
+3
-3
+1
-1
+2
-2
+4
-4
+1
-1
+19
-27
+2
-2
+2
-3
| --- src/ajax.c | ||
| +++ src/ajax.c | ||
| @@ -46,12 +46,11 @@ | ||
| 46 | 46 | ** Requires that builtin_emit_script_fossil_bootstrap() has already been |
| 47 | 47 | ** called in order to initialize the window.fossil.page object. |
| 48 | 48 | */ |
| 49 | 49 | void ajax_emit_js_preview_modes(int addScriptTag){ |
| 50 | 50 | if(addScriptTag){ |
| 51 | - style_emit_script_tag(0,0); | |
| 52 | - CX("\n"); | |
| 51 | + style_script_begin(__FILE__,__LINE__); | |
| 53 | 52 | } |
| 54 | 53 | CX("fossil.page.previewModes={" |
| 55 | 54 | "guess: %d, %d: 'guess', wiki: %d, %d: 'wiki'," |
| 56 | 55 | "htmlIframe: %d, %d: 'htmlIframe', " |
| 57 | 56 | "htmlInline: %d, %d: 'htmlInline', " |
| @@ -61,11 +60,11 @@ | ||
| 61 | 60 | AJAX_RENDER_WIKI, AJAX_RENDER_WIKI, |
| 62 | 61 | AJAX_RENDER_HTML_IFRAME, AJAX_RENDER_HTML_IFRAME, |
| 63 | 62 | AJAX_RENDER_HTML_INLINE, AJAX_RENDER_HTML_INLINE, |
| 64 | 63 | AJAX_RENDER_PLAIN_TEXT, AJAX_RENDER_PLAIN_TEXT); |
| 65 | 64 | if(addScriptTag){ |
| 66 | - style_emit_script_tag(1,0); | |
| 65 | + style_script_end(); | |
| 67 | 66 | } |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | /* |
| 71 | 70 | ** Returns a value from the ajax_render_modes enum, based on the |
| 72 | 71 |
| --- 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 @@ | ||
| 316 | 316 | switch( builtin.eDelivery ){ |
| 317 | 317 | case JS_INLINE: { |
| 318 | 318 | CX("<script nonce='%h'>\n",style_nonce()); |
| 319 | 319 | do{ |
| 320 | 320 | int i = builtin.aReq[builtin.nSent++]; |
| 321 | - CX("/* %s */\n", aBuiltinFiles[i].zName); | |
| 321 | + CX("/* %s %.60c*/\n", aBuiltinFiles[i].zName, '*'); | |
| 322 | 322 | cgi_append_content((const char*)aBuiltinFiles[i].pData, |
| 323 | 323 | aBuiltinFiles[i].nByte); |
| 324 | 324 | }while( builtin.nSent<builtin.nReq ); |
| 325 | 325 | CX("</script>\n"); |
| 326 | 326 | break; |
| @@ -592,11 +592,11 @@ | ||
| 592 | 592 | if(0==once++){ |
| 593 | 593 | char * zName; |
| 594 | 594 | /* Set up the generic/app-agnostic parts of window.fossil |
| 595 | 595 | ** which require C-level state... */ |
| 596 | 596 | if(addScriptTag!=0){ |
| 597 | - style_emit_script_tag(0,0); | |
| 597 | + style_script_begin(__FILE__,__LINE__); | |
| 598 | 598 | } |
| 599 | 599 | CX("(function(){\n"); |
| 600 | 600 | CX(/*MSIE NodeList.forEach polyfill, courtesy of Mozilla: |
| 601 | 601 | https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill |
| 602 | 602 | */ |
| @@ -655,11 +655,11 @@ | ||
| 655 | 655 | CX("window.fossil.page = {" |
| 656 | 656 | "name:\"%T\"" |
| 657 | 657 | "};\n", g.zPath); |
| 658 | 658 | CX("})();\n"); |
| 659 | 659 | if(addScriptTag!=0){ |
| 660 | - style_emit_script_tag(1,0); | |
| 660 | + style_script_end(); | |
| 661 | 661 | } |
| 662 | 662 | /* The remaining window.fossil bootstrap code is not dependent on |
| 663 | 663 | ** C-runtime state... */ |
| 664 | 664 | builtin_request_js("fossil.bootstrap.js"); |
| 665 | 665 | } |
| 666 | 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 */\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 @@ | ||
| 562 | 562 | */ |
| 563 | 563 | void captcha_speakit_button(unsigned int uSeed, const char *zMsg){ |
| 564 | 564 | if( zMsg==0 ) zMsg = "Speak the text"; |
| 565 | 565 | @ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \ |
| 566 | 566 | @ id="speakthetext"> |
| 567 | - @ <script nonce="%h(style_nonce())"> | |
| 567 | + @ <script nonce="%h(style_nonce())">/* captcha_speakit_button() */ | |
| 568 | 568 | @ document.getElementById("speakthetext").onclick = function(){ |
| 569 | 569 | @ var audio = window.fossilAudioCaptcha \ |
| 570 | 570 | @ || new Audio("%R/captcha-audio/%u(uSeed)"); |
| 571 | 571 | @ window.fossilAudioCaptcha = audio; |
| 572 | 572 | @ audio.currentTime = 0; |
| 573 | 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())"> |
| 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 @@ | ||
| 408 | 408 | void document_emit_js(void){ |
| 409 | 409 | if(!builtin_bundle_all_fossil_js_apis()){ |
| 410 | 410 | builtin_emit_fossil_js_apis("dom", "copybutton", |
| 411 | 411 | "pikchr", 0); |
| 412 | 412 | } |
| 413 | - style_emit_script_tag(0,0); | |
| 413 | + style_script_begin(__FILE__,__LINE__); | |
| 414 | 414 | CX("window.addEventListener('load', " |
| 415 | 415 | "()=>window.fossil.pikchr.addSrcView(), " |
| 416 | 416 | "false);\n"); |
| 417 | - style_emit_script_tag(1,0); | |
| 417 | + style_script_end(); | |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /* |
| 421 | 421 | ** Guess the mime-type of a document based on its name. |
| 422 | 422 | */ |
| 423 | 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_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 @@ | ||
| 1666 | 1666 | ** don't want inadvertently being used by other pages. We don't |
| 1667 | 1667 | ** have a common, page-specific container we can filter our CSS |
| 1668 | 1668 | ** selectors, but we do have the BODY, which we can decorate with |
| 1669 | 1669 | ** whatever CSS we wish... |
| 1670 | 1670 | */ |
| 1671 | - style_emit_script_tag(0,0); | |
| 1671 | + style_script_begin(__FILE__,__LINE__); | |
| 1672 | 1672 | CX("document.body.classList.add('fileedit');\n"); |
| 1673 | - style_emit_script_tag(1,0); | |
| 1673 | + style_script_end(); | |
| 1674 | 1674 | |
| 1675 | 1675 | /* Status bar */ |
| 1676 | 1676 | CX("<div id='fossil-status-bar' " |
| 1677 | 1677 | "title='Status message area. Double-click to clear them.'>" |
| 1678 | 1678 | "Status messages will go here.</div>\n" |
| @@ -2009,11 +2009,11 @@ | ||
| 2009 | 2009 | { |
| 2010 | 2010 | /* Dynamically populate the editor, display any error in the err |
| 2011 | 2011 | ** blob, and/or switch to tab #0, where the file selector |
| 2012 | 2012 | ** lives. The extra C scopes here correspond to JS-level scopes, |
| 2013 | 2013 | ** to improve grokability. */ |
| 2014 | - style_emit_script_tag(0,0); | |
| 2014 | + style_script_begin(__FILE__,__LINE__); | |
| 2015 | 2015 | CX("\n(function(){\n"); |
| 2016 | 2016 | CX("try{\n"); |
| 2017 | 2017 | { |
| 2018 | 2018 | char * zFirstLeafUuid = 0; |
| 2019 | 2019 | CX("fossil.config['fileedit-glob'] = "); |
| @@ -2058,12 +2058,12 @@ | ||
| 2058 | 2058 | } |
| 2059 | 2059 | CX("}catch(e){" |
| 2060 | 2060 | "fossil.error(e); console.error('Exception:',e);" |
| 2061 | 2061 | "}\n"); |
| 2062 | 2062 | CX("})();")/*anonymous function*/; |
| 2063 | - style_emit_script_tag(1,0); | |
| 2063 | + style_script_end(); | |
| 2064 | 2064 | } |
| 2065 | 2065 | blob_reset(&err); |
| 2066 | 2066 | CheckinMiniInfo_cleanup(&cimi); |
| 2067 | 2067 | db_end_transaction(0); |
| 2068 | 2068 | style_footer(); |
| 2069 | 2069 | } |
| 2070 | 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_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 @@ | ||
| 2444 | 2444 | }else if( renderAsHtml ){ |
| 2445 | 2445 | @ <iframe src="%R/raw/%s(zUuid)" |
| 2446 | 2446 | @ width="100%%" frameborder="0" marginwidth="0" marginheight="0" |
| 2447 | 2447 | @ sandbox="allow-same-origin" id="ifm1"> |
| 2448 | 2448 | @ </iframe> |
| 2449 | - @ <script nonce="%h(style_nonce())"> | |
| 2449 | + @ <script nonce="%h(style_nonce())">/* info.c:%d(__LINE__) */ | |
| 2450 | 2450 | @ document.getElementById("ifm1").addEventListener("load", |
| 2451 | 2451 | @ function(){ |
| 2452 | 2452 | @ this.height=this.contentDocument.documentElement.scrollHeight + 75; |
| 2453 | 2453 | @ } |
| 2454 | 2454 | @ ); |
| 2455 | 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())"> |
| 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 @@ | ||
| 714 | 714 | int nDelay = db_get_int("auto-hyperlink-delay",0); |
| 715 | 715 | int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0); |
| 716 | 716 | @ <script id='href-data' type='application/json'>\ |
| 717 | 717 | @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script> |
| 718 | 718 | } |
| 719 | - @ <script nonce="%h(style_nonce())"> | |
| 719 | + @ <script nonce="%h(style_nonce())">/* style.c:%d(__LINE__) */ | |
| 720 | 720 | @ function debugMsg(msg){ |
| 721 | 721 | @ var n = document.getElementById("debugMsg"); |
| 722 | 722 | @ if(n){n.textContent=msg;} |
| 723 | 723 | @ } |
| 724 | 724 | if( needHrefJs ){ |
| @@ -1428,37 +1428,29 @@ | ||
| 1428 | 1428 | va_end(vargs); |
| 1429 | 1429 | fossil_free(zLabelID); |
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | 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. | |
| 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 | 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 | - } | |
| 1450 | +void style_script_end(void){ | |
| 1451 | + CX("</script>\n"); | |
| 1460 | 1452 | } |
| 1461 | 1453 | |
| 1462 | 1454 | /* |
| 1463 | 1455 | ** Emits a NOSCRIPT tag with an error message stating that JS is |
| 1464 | 1456 | ** required for the current page. This "should" be called near the top |
| 1465 | 1457 |
| --- 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 @@ | ||
| 1291 | 1291 | } |
| 1292 | 1292 | builtin_request_js("sbsdiff.js"); |
| 1293 | 1293 | builtin_request_js("fossil.page.wikiedit.js"); |
| 1294 | 1294 | builtin_fulfill_js_requests(); |
| 1295 | 1295 | /* Dynamically populate the editor... */ |
| 1296 | - style_emit_script_tag(0,0); | |
| 1296 | + style_script_begin(__FILE__,__LINE__); | |
| 1297 | 1297 | { |
| 1298 | 1298 | /* Render the current page list to save us an XHR request |
| 1299 | 1299 | during page initialization. This must be OUTSIDE of |
| 1300 | 1300 | an onPageLoad() handler or else it does not get applied |
| 1301 | 1301 | until after the wiki list widget is initialized. Similarly, |
| @@ -1330,11 +1330,11 @@ | ||
| 1330 | 1330 | } |
| 1331 | 1331 | CX("}catch(e){" |
| 1332 | 1332 | "fossil.error(e); console.error('Exception:',e);" |
| 1333 | 1333 | "}\n"); |
| 1334 | 1334 | CX("});\n"/*fossil.onPageLoad()*/); |
| 1335 | - style_emit_script_tag(1,0); | |
| 1335 | + style_script_end(); | |
| 1336 | 1336 | style_footer(); |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | /* |
| 1340 | 1340 | ** WEBPAGE: wikinew |
| 1341 | 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_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 |