Files
Claude 56f022c8aa Image boards: Flash (SWF and FLV), played by Ruffle
A board takes Flash when its files say swf or flv (bbs chan board set f
files swf,flv), as 4chan's /f/ did, and [chan] ruffle names Ruffle's
self-hosted package (make ruffle fetches it from npm into ruffle/).

- SWF: FWS and CWS read for the stage, frames, rate and sounds, the
  tags walked as they unpack with nothing kept (a zlib bomb costs no
  memory and is refused); ZWS (LZMA) taken as 550x400 with sound
- FLV: onMetaData (AMF0) for size and length, the tags for sound and
  the video codec (Sorenson, Screen, VP6, VP6 alpha, H.264); ffmpeg
  thumbnails it, a movie gets a card
- sound needs the board's sound; an FLV is held to max_video

Clicking a Flash thumbnail plays it in a sandboxed frame (/chan/flash:
allow-scripts alone, by its CSP and the frame's attribute): no origin,
no cookies, nothing of the page.  The page fetches the file with its own
cookies and hands the bytes over; Ruffle runs with networking, scripting
and links off.  Ruffle 0.7.1 does not play a standalone FLV, so the BBS
makes a small AVM1 movie of its own (/chan/flvplayer.swf: NetStream
into a Video of the FLV's size) that plays it from a blob of the frame.
Ruffle's files are served at /chan/ruffle/ with CORS open (the frame
has no origin), only the package's .js, .wasm and .map.

Played in Chromium with Ruffle 0.7.1: a movie, and a Sorenson FLV with
sound through the player; both frames of origin "null", cookies
refused, no CSP violations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-14 10:31:03 +00:00

40 lines
1.6 KiB
JavaScript

// The Flash player's frame: sandboxed (no origin, no cookies, nothing of
// the page's), it takes a movie from the page that framed it and plays it
// in Ruffle. A movie may not reach the network, open pages or call any
// script; an FLV is played by the board's own player movie, from a blob
// of this frame's.
(function () {
"use strict";
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
publicPath: "/chan/ruffle/",
polyfills: false,
autoplay: "on",
unmuteOverlay: "visible",
splashScreen: false,
letterbox: "on",
allowScriptAccess: false,
allowNetworking: "none",
openUrlMode: "deny",
showSwfDownload: false,
upgradeToHttps: true,
warnOnUnsupportedContent: false,
logLevel: "error"
};
window.addEventListener("message", function (e) {
if (e.source !== window.parent || !e.data || typeof e.data !== "object") return;
var p = window.RufflePlayer.newest().createPlayer();
document.getElementById("player").append(p);
if (e.data.swf instanceof ArrayBuffer) {
p.ruffle().load({data: new Uint8Array(e.data.swf)});
} else if (e.data.flv instanceof ArrayBuffer && e.data.player instanceof ArrayBuffer) {
var src = URL.createObjectURL(new Blob([e.data.flv], {type: "video/x-flv"}));
// the player is ours: it may load the FLV (a blob of this frame)
p.ruffle().load({data: new Uint8Array(e.data.player), parameters: {src: src}, allowNetworking: "all"});
}
});
window.addEventListener("DOMContentLoaded", function () {
window.parent.postMessage("ready", "*");
});
})();