.
D 2026-08-17T17:39:54.864
J comment A\srepository's\sown\sdocumentation\sis\scurrently\sunreadable:\s`/r/fossil/file/trunk/www/permutedindex.html`\sshows\sHTML\ssource\swhere\sfossil\sshows\sa\srendered\sindex.\sFossil\sserves\sthese\sthrough\sa\sseparate\s`/doc/CHECKIN/FILE`\sroute;\squarry\shas\sno\sequivalent,\sso\s`file/`\sis\sthe\sonly\sview\sand\sit\sis\sa\ssource\sview\sby\sdesign.\n\n##\sHow\sfossil\sdoes\sit\n\n`document_render()`\s(src/doc.c)\sdispatches\son\smimetype:\n\n-\s`text/x-fossil-wiki`,\s`text/x-markdown`,\s`text/x-pikchr`\s—\sthrough\sits\sconverters\n-\s`text/html`\s—\s**only\sif**\s`doc_is_embedded_html()`\spasses,\swhich\srequires\sthe\sfile\sto\sbegin\swith\s`<div\sclass='fossil-doc'>`.\sFossil\sthen\swraps\sit\sin\ssite\schrome,\slifts\s`data-title`\sas\sthe\spage\stitle,\sand\spipes\sthe\sbody\sthrough\s`convert_href_and_output()`\n-\sanything\selse\s—\sthe\sbare\s`else`:\s`cgi_set_content_type(zMime);\scgi_set_content(pBody);`.\sRaw\sbytes,\sthe\sfile's\sown\scontent\stype,\sno\sfiltering\n\nFossil\sdoes\s**not**\ssanitize\sembedded\sdocuments.\sIts\sgate\sis\sa\sCSP\s(src/style.c:631):\n\n\s\s\s\sdefault-src\s'self'\sdata:;\sscript-src\s'self'\s'nonce-$nonce';\n\s\s\s\sstyle-src\s'self'\s'unsafe-inline';\simg-src\s*\sdata:\n\nInline\sscript\scannot\srun\swithout\sthe\sper-response\snonce,\swhich\srepository\scontent\scannot\sknow.\sNote\s`script-src\s'self'`\sstill\spermits\sa\scommitted\s`.js`\sreferenced\sby\s`src`,\sso\sthe\smodel\salso\sleans\son\soperator\strust\splus\sthe\s`default-csp`\ssetting.\n\nThe\swrapper\sis\sa\sreal\sconvention,\snot\sincidental:\sof\sthe\s10\s`.html`\sfiles\sin\sfossil's\stree,\sexactly\s3\scarry\s`class='fossil-doc'`\s—\s`www/permutedindex.html`,\s`www/caps/ref.html`,\s`www/server/index.html`.\sThe\sother\sseven\sare\smeant\sto\sbe\sserved\sraw.\n\nFossil\snever\srewrites\srelative\slinks.\sIt\sdoes\snot\sneed\sto:\sat\s`/doc/trunk/www/permutedindex.html`\sa\sbare\s`quickstart.wiki`\shref\sresolves\sto\s`/doc/trunk/www/quickstart.wiki`\son\sits\sown.\sOnly\s`$ROOT`\sand\s`$CURRENT`\sare\sexpanded,\sand\snarrowly\s—\sinside\sa\stag,\safter\s`href=`\sor\s`action=`\sonly.\sThat\spage\suses\s`$ROOT`\sfour\stimes.\n\n##\sWhat\squarry\salready\shas\n\n`renderBody`\s(internal/api/register.go:1857)\sis\salready\sfossil's\smimetype\sswitch.\s`markup.Render`\s/\s`RenderFossilWiki`\s/\s`RenderPikchr`\sare\sthe\sthree\sconverters.\s`file.get`\salready\sresolves\ssymbolic\sversions\slike\s`trunk`\sthrough\szit.\sA\s`/r/{repo}/doc/{version}/{path...}`\sroute\shas\sthe\ssame\sshape\sas\sthe\sexisting\sfile\sroute,\sso\srelative\slinks\scome\sfree\sexactly\sas\sthey\sdo\sfor\sfossil.\n\n##\sWhat\sis\smissing\n\n1.\s`/r/{repo}/doc/{version}/{path...}`\sroute\sand\sa\s`doc.get`\sop\n2.\sEmbedded-HTML\sdetection\sand\stitle\sextraction\s(~40\slines;\s`doc_is_embedded_html`\sfully\sspecifies\sit).\sThe\stitle\smust\sbe\sread\sBEFORE\ssanitizing\s—\sthe\spolicy\sstrips\s`class`\sand\s`data-title`\sfrom\sthe\swrapper\sdiv\n3.\s`$ROOT`\s/\s`$CURRENT`\sexpansion\s(~30\slines)\n4.\sRaw\spassthrough\sfor\snon-document\stypes\s(images,\sCSS)\sso\sreferenced\sassets\sresolve.\sThis\sis\swhere\scontent-type\sand\sCSP\sdecisions\slive,\sand\sit\sis\sa\ssecurity\sdecision\srather\sthan\sa\srendering\sone\n\n##\sMeasured:\sthe\sexisting\spolicy\sis\snearly\ssufficient\n\nRunning\s`markup.Sanitize`\sover\s`www/permutedindex.html`\s(8,754\sbytes):\n\n-\s125\sof\s126\slinks\ssurvive\n-\sall\s126\slist\sitems\ssurvive\n-\sthe\s`id`\sanchor\ssurvives\n-\s**lost**:\sthe\ssearch\s`<form>`,\sand\s`class`/`data-title`\son\sthe\swrapper\sdiv\n\n##\sDecision\sto\smake\n\nFossil's\sanswer\sto\shostile\sHTML\sis\s*no\ssanitizer,\sone\sCSP*.\sQuarry\shas\s*a\ssanitizer,\sno\sdoc\sroute*.\sDoing\sboth\sis\sstrictly\sstronger\sthan\sfossil\sand\scosts\snothing\sextra\ssince\sthe\ssanitizer\sis\salready\swritten,\sfuzz-tested\sand\scorpus-gated\s—\sbut\ssome\slegitimate\spages\srender\sdegraded,\ssuch\sas\slosing\sthat\ssearch\sform.\n\nRecommendation:\sship\ssanitizer\s**and**\sCSP,\sthen\swiden\sthe\spolicy\sfrom\sevidence.\sThe\scorpus\snow\scarries\sfossil's,\stk's\sand\slibspatialite's\sreal\sdoc\strees\sto\swiden\sagainst,\swhich\sbeats\swidening\sfrom\simagination.\n\nEstimate:\sabout\sa\sday\sfor\sthe\sfossil-doc\spath\s(items\s1–3),\sanother\sday\sfor\sraw\spassthrough\s(item\s4).\n
J status Open
J title Render\sembedded\sdocumentation\sinstead\sof\sshowing\sHTML\ssource
K 6ff100027fb20471c973dcc2941412d6efd42f9a
U dmestas
Z 8e367f870175e8206c41f45ad99c97d5