Fossil

Check-in [ebf5b59570]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Put the javascript for SVG/source toggling inside of the safe-html nonce so that it survives safing.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ebf5b595704788c4e89704b7de38b7b23a663fa209edcab5330bd1212ff0b02c
User & Date: drh 2020-09-17 18:04:12.272
Context
2020-09-17
19:20
Cleanup the double-click source display for Pikchr. check-in: 5634dfeb2f user: drh tags: trunk
18:04
Put the javascript for SVG/source toggling inside of the safe-html nonce so that it survives safing. check-in: ebf5b59570 user: drh tags: trunk
17:58
Experimental double-click to toggle between SVG and pikchr source. check-in: 3c786c6fc3 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/markdown_html.c.
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437

438
439
440
441
442
443
444
    blob_appendf(ob, "<div class='pikchr-svg' style='%s'>\n", blob_str(&css));
    blob_append(ob, zOut, -1);
    blob_appendf(ob, "</div>\n");
    blob_reset(&css);
    blob_appendf(ob, "<pre class='pikchr-src' style='display:none;'>"
                     "%s</pre>\n", zIn);
    blob_appendf(ob, "</div>\n");
    blob_appendf(ob, "%s\n", zSafeNonce);
    blob_appendf(ob,
      "<script nonce='%s'>\n"
      "document.getElementById('svgid-%d').ondblclick=function(){\n"
      "  for(var c of this.children){"
      "    c.style.display = c.style.display=='none'?'block':'none';"
      "  }\n"
      "}\n"
      "</script>\n",
      style_nonce(), nSvg);

  }else{
    blob_appendf(ob, "<pre>\n%s\n</pre>\n", zOut);
  }
  fossil_free(zIn);
  free(zOut);
}








<









>







421
422
423
424
425
426
427

428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
    blob_appendf(ob, "<div class='pikchr-svg' style='%s'>\n", blob_str(&css));
    blob_append(ob, zOut, -1);
    blob_appendf(ob, "</div>\n");
    blob_reset(&css);
    blob_appendf(ob, "<pre class='pikchr-src' style='display:none;'>"
                     "%s</pre>\n", zIn);
    blob_appendf(ob, "</div>\n");

    blob_appendf(ob,
      "<script nonce='%s'>\n"
      "document.getElementById('svgid-%d').ondblclick=function(){\n"
      "  for(var c of this.children){"
      "    c.style.display = c.style.display=='none'?'block':'none';"
      "  }\n"
      "}\n"
      "</script>\n",
      style_nonce(), nSvg);
    blob_appendf(ob, "%s\n", zSafeNonce);
  }else{
    blob_appendf(ob, "<pre>\n%s\n</pre>\n", zOut);
  }
  fossil_free(zIn);
  free(zOut);
}