From 13a0205418cd57a2a60ed654affd2b344cb2d10b Mon Sep 17 00:00:00 2001 From: awakenginexe <267649137+awakenginexe@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:35:04 +0700 Subject: [PATCH 1/2] release: Awake Modpack Manager 1.4.1 --- README.md | 8 +++---- docs/HANDOFF.md | 6 +++--- docs/releases/v1.4.1.md | 20 ++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/providers.rs | 27 +++++++++++++++++------- src-tauri/tauri.conf.json | 4 ++-- src/backend/host.ts | 2 +- src/backend/mock/MockBackend.ts | 4 ++-- src/components/ProjectDialog.vue | 14 +++++++++---- src/i18n/en.ts | 4 ++++ src/i18n/th.ts | 4 ++++ src/i18n/zh-CN.ts | 4 ++++ src/i18n/zh-TW.ts | 4 ++++ src/state/nav.ts | 4 +++- src/ui/richText.ts | 36 ++++++++++++++++++++++++++++++++ src/views/BrowseView.vue | 5 +++-- src/views/ContentBrowseView.vue | 4 ++-- tests/richText.test.ts | 25 ++++++++++++++++++++-- 21 files changed, 149 insertions(+), 36 deletions(-) create mode 100644 docs/releases/v1.4.1.md diff --git a/README.md b/README.md index a26ddd1..b6acb6d 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ A Windows desktop app for building and maintaining Minecraft modpacks. It create projects and installs real mods from Modrinth, with every change reviewed before it is applied. Awake Launcher is not required. -> **What's new in 1.4.0:** see [docs/releases/v1.4.0.md](docs/releases/v1.4.0.md). +> **What's new in 1.4.1:** see [docs/releases/v1.4.1.md](docs/releases/v1.4.1.md). -**Version 1.4.0 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only** +**Version 1.4.1 · Windows x64 · English, ไทย, 简体中文, 繁體中文 · GPL-3.0-only** ## Install -1. Download `Awake-Modpack-Manager-v1.4.0-Windows-x64-Setup.exe` from the +1. Download `Awake-Modpack-Manager-v1.4.1-Windows-x64-Setup.exe` from the [latest release](https://github.com/awakenginexe/Awake-Modpack-Manager/releases/latest). 2. Optional: check it against `SHA256SUMS.txt` from the same release - (`Get-FileHash .\Awake-Modpack-Manager-v1.4.0-Windows-x64-Setup.exe`). + (`Get-FileHash .\Awake-Modpack-Manager-v1.4.1-Windows-x64-Setup.exe`). 3. Run the installer. It installs for your Windows user only (no administrator rights) into `%LOCALAPPDATA%\Awake Modpack Manager`. The installer is **not code-signed** yet, so Windows SmartScreen may warn that it is from an diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 0b6e6e6..960b144 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -1,10 +1,10 @@ -# Development checkpoint: Manager 1.4.0 and Native Core 0.4.2 +# Development checkpoint: Manager 1.4.1 and Native Core 0.4.2 -Unreleased until the owner approves the pull request and tags `v1.4.0`. +Unreleased until the owner approves the pull request and tags `v1.4.1`. ## Where things are -- Manager: branch `release/1.4.0`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`. +- Manager: branch `release/1.4.1`. `npm ci`, then `npm test`, `npm run typecheck`, `cargo test --manifest-path src-tauri/Cargo.toml --lib`. - Native Core: Awake Launcher branch `release/3.2.2`. `.github/workflows/native-core-package.yml` builds it with the recorded toolchain and commits a delivery under `native-core/redistribution//`. `scripts/helper-pin.json` pins that delivery. - Release: pushing a version tag runs `.github/workflows/awake-beta.yml`, which builds, verifies, assembles every asset and publishes the release. `SHA256SUMS.txt` is required by in-app updates. diff --git a/docs/releases/v1.4.1.md b/docs/releases/v1.4.1.md new file mode 100644 index 0000000..442247f --- /dev/null +++ b/docs/releases/v1.4.1.md @@ -0,0 +1,20 @@ +# Awake Modpack Manager 1.4.1 + +Works with **Awake Launcher 3.2.2** and newer. + +## New + +- **YouTube videos play on a project's page.** A YouTube video embedded in a mod, resource pack or shader description now plays in the project window. Other embedded pages are shown as a link; clicking it asks first, then opens it in your browser. +- **Your search stays when you come back.** What you typed on Browse (mods, resource packs and shaders, each separately) is kept while the Manager is open, so switching to another page and back no longer clears it. + +## Fixed + +- **Blurry screenshots on Modrinth project pages.** The large preview used Modrinth's small thumbnail; it now loads the original image. The strip under it still uses the small one, on both sites. + +## Safety + +Only YouTube can play inside the Manager. The player address is rebuilt from the video's id (the author's address is never used as is), it uses YouTube's no-cookie domain, runs in a sandbox that cannot navigate the Manager's window, and the app's content policy allows frames from that one domain only. + +## Not verified on a real machine yet + +Checked with the automated tests and the built-in demo data. Still unverified in the desktop app: a real YouTube video playing in the project window, and full-size Modrinth screenshots. diff --git a/package-lock.json b/package-lock.json index 1cdcc6e..5256bd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "awake-modpack-manager", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "awake-modpack-manager", - "version": "1.4.0", + "version": "1.4.1", "license": "GPL-3.0-only", "dependencies": { "@lucide/vue": "1.59.0", diff --git a/package.json b/package.json index 26bf0d1..805ef17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "awake-modpack-manager", "private": true, - "version": "1.4.0", + "version": "1.4.1", "license": "GPL-3.0-only", "type": "module", "engines": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index af186b1..b61ea66 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -224,7 +224,7 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "awake-modpack-manager" -version = "1.4.0" +version = "1.4.1" dependencies = [ "md-5", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e4c6f7e..1692820 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awake-modpack-manager" -version = "1.4.0" +version = "1.4.1" description = "Awake Modpack Manager desktop host" license = "GPL-3.0-only" repository = "https://github.com/awakenginexe/Awake-Modpack-Manager" diff --git a/src-tauri/src/providers.rs b/src-tauri/src/providers.rs index 078c142..aee6e41 100644 --- a/src-tauri/src/providers.rs +++ b/src-tauri/src/providers.rs @@ -1032,11 +1032,21 @@ pub struct ProjectDetail { /// The window renders it through an allowlist; nothing here is trusted. body: String, body_format: &'static str, - gallery: Vec, + gallery: Vec, } -/// Screenshots, at most 12, and only from https. -fn gallery(list: &Value, key: &str) -> Vec { - list.as_array().map_or(vec![], |g| g.iter().filter_map(|x| x[key].as_str()).filter(|u| u.starts_with("https://")).take(12).map(String::from).collect()) +#[derive(serde::Serialize, Debug, PartialEq)] +pub struct Shot { + full: String, + thumb: String, +} +/// Screenshots, at most 12, and only from https: the full image for the big view, the site's small one for the strip. +fn gallery(list: &Value, full: &str, thumb: &str) -> Vec { + let https = |v: &Value| v.as_str().filter(|u| u.starts_with("https://")).map(String::from); + list.as_array().map_or(vec![], |g| g.iter().filter_map(|x| { + let small = https(&x[thumb]); + let big = https(&x[full]).or(small.clone())?; + Some(Shot { thumb: small.unwrap_or(big.clone()), full: big }) + }).take(12).collect()) } pub fn parse_modrinth_detail(p: &Value, members: &Value) -> ProjectDetail { @@ -1051,7 +1061,8 @@ pub fn parse_modrinth_detail(p: &Value, members: &Value) -> ProjectDetail { page_url: Some(format!("https://modrinth.com/{}/{}", p["project_type"].as_str().filter(|t| ["resourcepack", "shader"].contains(t)).unwrap_or("mod"), s(p, "slug"))), body: s(p, "body").into(), body_format: "markdown", - gallery: gallery(&p["gallery"], "url"), + // Modrinth's `url` is a 350px webp; `raw_url` is the uploaded original. + gallery: gallery(&p["gallery"], "raw_url", "url"), } } pub fn parse_curseforge_detail(p: &Value, description: &str) -> ProjectDetail { @@ -1065,7 +1076,7 @@ pub fn parse_curseforge_detail(p: &Value, description: &str) -> ProjectDetail { page_url: p["links"]["websiteUrl"].as_str().filter(|u| u.starts_with("https://")).map(Into::into), body: description.into(), body_format: "html", - gallery: gallery(&p["screenshots"], "url"), + gallery: gallery(&p["screenshots"], "url", "thumbnailUrl"), } } @@ -1189,9 +1200,9 @@ mod tests { #[test] fn project_details_read_both_providers() { - let m = parse_modrinth_detail(&json!({"slug": "sodium", "description": "Fast", "downloads": 5.0, "updated": "2026-01-01T00:00:00Z", "license": {"id": "LGPL-3.0"}, "categories": ["optimization"], "project_type": "shader", "body": "# Hi", "gallery": [{"url": "https://cdn.modrinth.com/a.png"}, {"url": "http://plain/b.png"}]}), &json!([{"role": "Member", "user": {"username": "b"}}, {"role": "Owner", "user": {"username": "jelly"}}])); + let m = parse_modrinth_detail(&json!({"slug": "sodium", "description": "Fast", "downloads": 5.0, "updated": "2026-01-01T00:00:00Z", "license": {"id": "LGPL-3.0"}, "categories": ["optimization"], "project_type": "shader", "body": "# Hi", "gallery": [{"url": "https://cdn.modrinth.com/a_350.webp", "raw_url": "https://cdn.modrinth.com/a.png"}, {"url": "http://plain/b.png"}]}),&json!([{"role": "Member", "user": {"username": "b"}}, {"role": "Owner", "user": {"username": "jelly"}}])); assert_eq!((m.author.as_str(), m.license.as_deref(), m.page_url.as_deref()), ("jelly", Some("LGPL-3.0"), Some("https://modrinth.com/shader/sodium"))); - assert_eq!((m.body.as_str(), m.body_format, m.gallery), ("# Hi", "markdown", vec!["https://cdn.modrinth.com/a.png".to_string()])); + assert_eq!((m.body.as_str(), m.body_format, m.gallery), ("# Hi", "markdown", vec![Shot { full: "https://cdn.modrinth.com/a.png".into(), thumb: "https://cdn.modrinth.com/a_350.webp".into() }])); let c = parse_curseforge_detail(&json!({"authors": [{"name": "mezz"}], "summary": "Items", "downloadCount": 9.0, "categories": [{"name": "API"}], "links": {"websiteUrl": "https://www.curseforge.com/minecraft/mc-mods/jei"}, "screenshots": [{"url": "https://media.forgecdn.net/s.png"}]}), "

Items

"); assert_eq!((c.body.as_str(), c.body_format, c.gallery.len()), ("

Items

", "html", 1)); assert_eq!((c.author.as_str(), c.categories.len(), c.downloads), ("mezz", 1, Some(9.0))); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2a91def..89cfb39 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "Awake Modpack Manager", - "version": "1.4.0", + "version": "1.4.1", "identifier": "io.github.awakenginexe.AwakeModpackManager", "build": { "frontendDist": "../dist", @@ -25,7 +25,7 @@ } ], "security": { - "csp": "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; font-src 'self'; connect-src ipc: http://ipc.localhost", + "csp": "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; font-src 'self'; connect-src ipc: http://ipc.localhost; frame-src https://www.youtube-nocookie.com", "devCsp": null } }, diff --git a/src/backend/host.ts b/src/backend/host.ts index 6d4793b..1dba616 100644 --- a/src/backend/host.ts +++ b/src/backend/host.ts @@ -4,7 +4,7 @@ import { BackendError, type AddedContent, type ContentEntry, type ContentImage, export interface FetchedPack { token: string; format: 'mrpack' | 'curseforge'; size: number; sha256: string; notes: string[] } export interface ProjectMeta { provider: ProviderId; projectId: string; name: string; iconUrl?: string; restricted?: boolean; pageUrl?: string } export interface ModUpdate { provider: ProviderId; projectId: string; installedVersionId: string; candidate: { id: string; name: string; releaseType: 'release' | 'beta' | 'alpha' } | null } -export interface ProjectDetail { author: string; summary: string; downloads: number | null; updatedAt: string | null; license: string | null; categories: string[]; pageUrl: string | null; body?: string; bodyFormat?: 'markdown' | 'html'; gallery?: string[] } +export interface ProjectDetail { author: string; summary: string; downloads: number | null; updatedAt: string | null; license: string | null; categories: string[]; pageUrl: string | null; body?: string; bodyFormat?: 'markdown' | 'html'; gallery?: { full: string; thumb: string }[] } export interface ProjectRef { provider: ProviderId; projectId: string; versionId?: string } /** diff --git a/src/backend/mock/MockBackend.ts b/src/backend/mock/MockBackend.ts index 40a9425..25c4592 100644 --- a/src/backend/mock/MockBackend.ts +++ b/src/backend/mock/MockBackend.ts @@ -591,8 +591,8 @@ export class MockBackend implements ManagerBackend { bodyFormat: provider === 'curseforge' ? 'html' as const : 'markdown' as const, body: provider === 'curseforge' ? '

About

A demo page written as HTML.

  • One thing
  • Another
' - : '# About\n\nA **demo** page written as Markdown, with a [link](https://example.com/).\n\n## Features\n\n- One thing\n- Another\n\n```\n/give @s demo\n```', - gallery: [shot(seed % 360), shot((seed + 120) % 360), shot((seed + 240) % 360)], + : '# About\n\nA **demo** page written as Markdown, with a [link](https://example.com/).\n\n## Features\n\n- One thing\n- Another\n\n```\n/give @s demo\n```\n\n## Showcase\n\n\n\n', + gallery: [seed, seed + 120, seed + 240].map((h) => ({ full: shot(h % 360), thumb: shot(h % 360) })), }; } diff --git a/src/components/ProjectDialog.vue b/src/components/ProjectDialog.vue index 5adb4b7..0fb8985 100644 --- a/src/components/ProjectDialog.vue +++ b/src/components/ProjectDialog.vue @@ -6,6 +6,7 @@ import type { ProjectDetail } from '../backend/host'; import { formatDate, formatNumber, t } from '../i18n'; import { openExternal } from '../state/appUpdate'; import { useSession } from '../state/session'; +import { confirmDialog } from '../ui/desktop'; import { renderRich } from '../ui/richText'; import Avatar from './Avatar.vue'; import ProviderLogo from './ProviderLogo.vue'; @@ -42,7 +43,10 @@ function onBodyClick(event: MouseEvent) { const link = (event.target as HTMLElement).closest('a'); if (!link) return; event.preventDefault(); - void openExternal(link.href); + if (link.dataset.embed === undefined) { void openExternal(link.href); return; } + const host = new URL(link.href).host; + void confirmDialog({ title: t('detailEmbedTitle'), body: t('detailEmbedBody', { host }), details: [link.href], confirm: t('detailEmbedConfirm'), cancel: t('cancel') }) + .then((ok) => { if (ok) void openExternal(link.href); }); } @@ -68,10 +72,10 @@ function onBodyClick(event: MouseEvent) {
{{ c }}
@@ -119,6 +123,8 @@ function onBodyClick(event: MouseEvent) { .rich :deep(p), .rich :deep(ul), .rich :deep(ol), .rich :deep(blockquote), .rich :deep(pre), .rich :deep(table) { margin: 0 0 0.8em; } .rich :deep(ul), .rich :deep(ol) { padding-left: 1.4em; } .rich :deep(img) { max-width: 100%; height: auto; border-radius: 6px; } +.rich :deep(iframe.video) { display: block; width: 100%; max-width: 720px; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: 8px; background: rgba(0, 0, 0, 0.35); margin: 0 0 0.8em; } +.rich :deep(a.embed-link) { display: inline-flex; padding: 8px 12px; margin: 0 0 0.8em; border: 1px solid var(--border-subtle); border-radius: 8px; background: rgba(255, 255, 255, 0.04); text-decoration: none; } .rich :deep(a) { color: #7dd3fc; text-decoration: underline; text-underline-offset: 2px; } .rich :deep(code) { font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 4px; } .rich :deep(pre) { background: rgba(0, 0, 0, 0.35); padding: 12px; border-radius: 8px; overflow-x: auto; } diff --git a/src/i18n/en.ts b/src/i18n/en.ts index e7e2e79..d978e99 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -813,6 +813,10 @@ export const en = { detailGallery: "Screenshots", detailShot: "Screenshot {n}", detailNoBody: "This project has no description on its page.", + detailEmbedOpen: "Embedded content from {host}: open in browser", + detailEmbedTitle: "Open this in your browser?", + detailEmbedBody: "The description embeds a page from {host}. Only YouTube videos play inside the Manager; this one opens in your browser.", + detailEmbedConfirm: "Open in browser", } as const; export type MessageKey = keyof typeof en; diff --git a/src/i18n/th.ts b/src/i18n/th.ts index 506a67a..4907f93 100644 --- a/src/i18n/th.ts +++ b/src/i18n/th.ts @@ -815,4 +815,8 @@ export const th: Catalog = { detailGallery: "ภาพหน้าจอ", detailShot: "ภาพหน้าจอ {n}", detailNoBody: "โปรเจกต์นี้ไม่มีคำอธิบายบนหน้าเว็บ", + detailEmbedOpen: "เนื้อหาฝังจาก {host}: เปิดในเบราว์เซอร์", + detailEmbedTitle: "เปิดในเบราว์เซอร์ไหม?", + detailEmbedBody: "คำอธิบายนี้ฝังหน้าเว็บจาก {host} ไว้ ตัวจัดการเล่นได้เฉพาะวิดีโอ YouTube ภายในแอป ลิงก์นี้จะเปิดในเบราว์เซอร์ของคุณ", + detailEmbedConfirm: "เปิดในเบราว์เซอร์", }; diff --git a/src/i18n/zh-CN.ts b/src/i18n/zh-CN.ts index 32ee94c..8896811 100644 --- a/src/i18n/zh-CN.ts +++ b/src/i18n/zh-CN.ts @@ -815,4 +815,8 @@ export const zhCN: Catalog = { detailGallery: "截图", detailShot: "截图 {n}", detailNoBody: "此项目的页面上没有说明。", + detailEmbedOpen: "来自 {host} 的嵌入内容:在浏览器中打开", + detailEmbedTitle: "在浏览器中打开?", + detailEmbedBody: "说明中嵌入了来自 {host} 的页面。管理器内只播放 YouTube 视频,此链接将在浏览器中打开。", + detailEmbedConfirm: "在浏览器中打开", }; diff --git a/src/i18n/zh-TW.ts b/src/i18n/zh-TW.ts index e50ea03..b6c034a 100644 --- a/src/i18n/zh-TW.ts +++ b/src/i18n/zh-TW.ts @@ -815,4 +815,8 @@ export const zhTW: Catalog = { detailGallery: "螢幕截圖", detailShot: "螢幕截圖 {n}", detailNoBody: "此專案的頁面上沒有說明。", + detailEmbedOpen: "來自 {host} 的嵌入內容:在瀏覽器中開啟", + detailEmbedTitle: "在瀏覽器中開啟?", + detailEmbedBody: "說明中嵌入了來自 {host} 的頁面。管理器內只播放 YouTube 影片,此連結將在瀏覽器中開啟。", + detailEmbedConfirm: "在瀏覽器中開啟", }; diff --git a/src/state/nav.ts b/src/state/nav.ts index 7890173..9d92d06 100644 --- a/src/state/nav.ts +++ b/src/state/nav.ts @@ -1,9 +1,11 @@ -import { ref, shallowRef } from 'vue'; +import { reactive, ref, shallowRef } from 'vue'; import type { ContentArea, ContentKind } from '../backend/contract'; /** What Browse is showing: mods go through a reviewed plan, resource packs and shaders install directly. */ export type BrowseKind = 'mod' | ContentKind; export const browseKind = ref('mod'); +/** What was typed in each Browse search, kept while the app runs so leaving the screen doesn't clear it. */ +export const browseText = reactive>({ mod: '', resourcepack: '', shader: '' }); /** * Set by a screen that may hold unsaved work (the file editor). Asked before another screen diff --git a/src/ui/richText.ts b/src/ui/richText.ts index e955ba6..e816ada 100644 --- a/src/ui/richText.ts +++ b/src/ui/richText.ts @@ -2,7 +2,9 @@ * Project descriptions come from Modrinth (Markdown, often with HTML in it) and CurseForge (HTML), written by * anyone. They are never inserted as HTML: the text is parsed into an inert document and rebuilt from an * allowlist of plain formatting tags, https links and https images. Everything else is dropped or unwrapped. + * The one frame allowed is a YouTube player whose URL is rebuilt from the video id. */ +import { t } from '../i18n'; const KEEP = new Set(['p', 'br', 'hr', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong', 'b', 'em', 'i', 'u', 's', 'del', 'code', 'pre', 'blockquote', 'ul', 'ol', 'li', 'a', 'img', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'details', 'summary', 'center', 'sub', 'sup', 'kbd']); @@ -10,11 +12,45 @@ const KEEP = new Set(['p', 'br', 'hr', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'stro const DROP = new Set(['script', 'style', 'iframe', 'object', 'embed', 'form', 'input', 'button', 'textarea', 'select', 'svg', 'math', 'link', 'meta', 'base', 'template', 'noscript', 'video', 'audio', 'title', 'head']); const web = (url: string | null) => (url && /^https:\/\/[^\s"'<>]+$/i.test(url.trim()) ? url.trim() : null); +/** The video id of a YouTube embed or watch link, or null. Only the id is kept: the player URL is rebuilt from it. */ +export function youtubeId(url: string | null): string | null { + const m = /^https:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:embed\/|shorts\/|watch\?(?:[^#]*&)?v=)|youtu\.be\/)([\w-]{11})(?![\w-])/i.exec(url?.trim() ?? ''); + return m?.[1] ?? null; +} + +/** A frame from the description: YouTube plays in a locked-down player, anything else becomes a link that asks before opening. */ +function embed(el: Element, to: Node, doc: Document) { + const src = el.getAttribute('src'); + const id = youtubeId(src); + if (id) { + const frame = doc.createElement('iframe'); + frame.src = `https://www.youtube-nocookie.com/embed/${id}`; + frame.className = 'video'; + frame.title = 'YouTube'; + frame.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-presentation'); + frame.setAttribute('allow', 'encrypted-media; picture-in-picture; fullscreen'); + frame.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin'); + frame.setAttribute('loading', 'lazy'); + to.appendChild(frame); + return; + } + const href = web(src); + if (!href) return; + const link = doc.createElement('a'); + link.href = href; + link.rel = 'noreferrer noopener'; + link.className = 'embed-link'; + link.dataset.embed = ''; + link.textContent = t('detailEmbedOpen', { host: new URL(href).host }); + to.appendChild(link); +} + function copy(from: Node, to: Node, doc: Document) { for (const node of Array.from(from.childNodes)) { if (node.nodeType === 3) { to.appendChild(doc.createTextNode(node.textContent ?? '')); continue; } if (node.nodeType !== 1) continue; const el = node as Element, tag = el.tagName.toLowerCase(); + if (tag === 'iframe') { embed(el, to, doc); continue; } if (DROP.has(tag)) continue; if (!KEEP.has(tag)) { copy(el, to, doc); continue; } // unknown wrapper (div, span, font): keep its text const out = doc.createElement(tag); diff --git a/src/views/BrowseView.vue b/src/views/BrowseView.vue index 998c9e9..cb3391f 100644 --- a/src/views/BrowseView.vue +++ b/src/views/BrowseView.vue @@ -1,5 +1,6 @@ ' + const out = html('

Hi there

' + '' + 'badgood
', 'html'); expect(out).toBe('

Hi there

badgood'); @@ -32,4 +32,25 @@ describe('project descriptions', () => { expect(out).toContain('
'); expect(out).not.toMatch(/script|javascript|alert/); }); + + it('plays YouTube in a locked-down player and turns other frames into links', () => { + expect(youtubeId('https://www.youtube.com/embed/dQw4w9WgXcQ?si=x')).toBe('dQw4w9WgXcQ'); + expect(youtubeId('https://youtu.be/dQw4w9WgXcQ')).toBe('dQw4w9WgXcQ'); + expect(youtubeId('https://www.youtube.com/watch?list=a&v=dQw4w9WgXcQ')).toBe('dQw4w9WgXcQ'); + expect(youtubeId('https://www.youtube.com.evil.io/embed/dQw4w9WgXcQ')).toBeNull(); + expect(youtubeId('https://evil.io/youtu.be/dQw4w9WgXcQ')).toBeNull(); + expect(youtubeId('http://www.youtube.com/embed/dQw4w9WgXcQ')).toBeNull(); + + const out = html('', 'html'); + const host = document.createElement('div'); + host.innerHTML = out; + const [frame] = host.querySelectorAll('iframe'); + expect(host.querySelectorAll('iframe')).toHaveLength(1); + expect(frame!.getAttribute('src')).toBe('https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ'); + expect(frame!.getAttribute('sandbox')).toBe('allow-scripts allow-same-origin allow-presentation'); + expect(frame!.hasAttribute('onload') || frame!.hasAttribute('width')).toBe(false); + const link = host.querySelector('a[data-embed]'); + expect(link?.getAttribute('href')).toBe('https://evil.io/page'); + expect(link?.textContent).toContain('evil.io'); + }); }); From ec891f93e64468a7cfe009a3baee3faa43c88cab Mon Sep 17 00:00:00 2001 From: awakenginexe <267649137+awakenginexe@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:40:36 +0700 Subject: [PATCH 2/2] test: give view tests room on slow CI runners --- vite.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 2a09306..199c806 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,5 +8,6 @@ export default defineConfig({ build: { target: 'es2022' }, // The Rust host rebuilds into src-tauri/target; watching it only produces busy-file errors. server: { watch: { ignored: ['**/src-tauri/**'] } }, - test: { environment: 'jsdom', include: ['tests/**/*.test.ts'] }, + // The first view a test file mounts compiles it; that alone can pass 5 s on a busy CI runner. + test: { environment: 'jsdom', include: ['tests/**/*.test.ts'], testTimeout: 30_000 }, });