Repository navigation
Allow rendering HTML pastes as sandboxed pages - #236
theryecatcher wants to merge 2 commits into
Conversation
9e4362c to
c406f83
Compare
matze
left a comment
There was a problem hiding this comment.
I will play further with it, thanks so far! Please also take a look at i18n.rs, paste.help.toggle_rendered is specific to Markdown.
| tracing::debug!("enforcing a http timeout of {timeout:#?}"); | ||
|
|
||
| if render_html { | ||
| tracing::warn!("serving html pastes as sandboxed pages at /html/{{id}}"); |
There was a problem hiding this comment.
Should that be a server-side warning though?
There was a problem hiding this comment.
Agreed it's not an abnormal condition, so I moved it to debug with the other startup settings. If you meant a warning for viewers instead, we could add it as a console log but unsure if that will help in any situation. Happy to add one if you think it's worth it.
|
Thanks for the comments !! I thought to take a look at the translation should have been a simple Google Translate will do that. The rest of the requested changes look straightforward enough will implement them too. The struct was definitely something I should have thought about too. |
I can check the German translation 👍 |
Let pastes be viewed as the page itself at `/html/{id}`, so self
contained documents with inline CSS, SVG and web fonts can be shared
directly instead of as highlighted source. The feature is opt-in through
`WASTEBIN_RENDER_UNTRUSTED_HTML`.
- Serve the paste unmodified under a CSP `sandbox` with no allow flags.
It gets an opaque origin with no access to wastebin cookies, and
scripts, forms, pop-ups and automatic redirects are blocked.
- Show a toggle to the page on `html` and `htm` pastes.
- Have handlers return a typed `Csp` that the security headers layer
writes as the only policy, defaulting to strict. As a side effrct
Markdown burn, password and error pages now get the strict policy too.
- Share the burn confirmation and password prompt flow across the
source, Markdown and HTML views, so each view only names the route its
prompts post back to.
The m key clicks the view toggle, which HTML pastes now have too, so it opens their sandboxed page. No wastebin script runs on that page, so m cannot toggle back.
c406f83 to
f04d060
Compare
Closes #235
Lets
.htmland.htmpastes be opened as the page, at/html/{id}, so documents with inline CSS, SVG and web fonts can be shared directly instead of as highlighted source. It is off by default and turned on withWASTEBIN_RENDER_UNTRUSTED_HTML=true.Security
/html/{id}are wastebin's own pages and keep the strict policy. To allow that, the security headers layer now keeps a CSP. Only/html/{id}sets it, so every other route should be unchanged./html/{id}returns wastebin's 404 page and no toggle is shown.Testing
All tests (including clippy) pass. Some new tests cover the sandbox, burn and password pastes, missing pastes and the default off behaviour.