-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Move asciicast renderer to iframe #37285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
silverwind
wants to merge
10
commits into
go-gitea:main
Choose a base branch
from
silverwind:cast
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
20d9d3b
Fix CSP blocking WebAssembly in asciicast renderer
silverwind c8dd3b5
Restore .ap-term overflow rule
silverwind 1ae0c95
Merge branch 'main' into cast
silverwind 1b91a49
Per-renderer iframe SrcMethod option, asciicast opts into "src"
silverwind ca0149c
Shorten comments; clean up switch in RenderFile
silverwind e03f3f0
Merge branch 'main' into cast
silverwind bbdde52
Generalize iframe CSP extension: AdditionalCSPSources
silverwind ac69eb3
Merge branch 'cast' of github.com:silverwind/gitea into cast
silverwind 2a69ae3
Address Copilot review: sandbox guard, generalize CSP builder, restor…
silverwind 1cddbb9
Merge branch 'main' into cast
silverwind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package repo | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestIframeSandboxSafeForSrc(t *testing.T) { | ||
| cases := []struct { | ||
| sandbox string | ||
| safe bool | ||
| }{ | ||
| {"", false}, | ||
| {"allow-scripts", true}, | ||
| {"allow-scripts allow-forms allow-popups", true}, | ||
| {"allow-scripts allow-same-origin", false}, | ||
| {"allow-same-origin", false}, | ||
| {" allow-scripts allow-same-origin ", false}, | ||
| } | ||
| for _, tc := range cases { | ||
| t.Run(tc.sandbox, func(t *testing.T) { | ||
| assert.Equal(t, tc.safe, iframeSandboxSafeForSrc(tc.sandbox)) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
web_src/css/markup/asciicast.css → .../js/render/plugins/frontend-asciicast.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
web_src/js/markup/asciicast.ts → ...c/js/render/plugins/frontend-asciicast.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,20 @@ | ||
| import {queryElems} from '../utils/dom.ts'; | ||
| import type {FrontendRenderFunc} from '../plugin.ts'; | ||
|
|
||
| export async function initMarkupRenderAsciicast(elMarkup: HTMLElement): Promise<void> { | ||
| queryElems(elMarkup, '.asciinema-player-container', async (el) => { | ||
| export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => { | ||
| try { | ||
| const [player] = await Promise.all([ | ||
| import('asciinema-player'), | ||
| import('asciinema-player/dist/bundle/asciinema-player.css'), | ||
| import('./frontend-asciicast.css'), | ||
| ]); | ||
|
|
||
| player.create(el.getAttribute('data-asciinema-player-src')!, el, { | ||
| player.create({data: opts.contentString()}, opts.container, { | ||
| // poster (a preview frame) to display until the playback is started. | ||
| // Set it to 1 hour (also means the end if the video is shorter) to make the preview frame show more. | ||
| poster: 'npt:1:0:0', | ||
| }); | ||
| }); | ||
| } | ||
| return true; | ||
| } catch (error) { | ||
| console.error(error); | ||
| return false; | ||
| } | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.