Skip to content

Commit 60e3c71

Browse files
committed
Stop archived pages navigating the tab to replayweb.page
Captures of press sites carry frame-busters (addthis, old Facebook/Twitter widgets, inline poll scripts). When one fires, wombat rewrites the top-level navigation to baseUrlSourcePrefix, which the player defaults to "https://replayweb.page/" whenever nobody sets it. The tab left islam.zmo.de for a third-party origin that has no copy of the collection: it 404s its own /w/api/c/<id> endpoint, then fails to load our .wacz cross-origin and shows "Unexpected Loading Error: <our file url>". The archive itself had loaded and replayed correctly a moment earlier — the visible flash was the real replay, before the navigation away. The block now emits <replay-web-page> directly instead of delegating to $media->render(), because the WebArchive module's template sets neither attribute needed to prevent this and exposes no way to pass them: sandbox the player only sandboxes its iframe when this is present, and that sandbox list omits allow-top-navigation, so the frame-bust cannot happen at all newWindowBase points baseUrlSourcePrefix at our own shell, keeping any escape that does occur same-origin Verified against the live site: sandbox resolves true, the rendered iframe carries no allow-top-navigation, and baseUrlSourcePrefix becomes the local asset path with replayweb.page gone from the parameters entirely. Bypassing the module renderer also bypasses its assertPlayable() guard against Content-Encoding on the file; the player uses range requests, which are never compressed, and the template comment records this as a tripwire. Also brings package-lock.json back in step with the other version files, which had drifted a release behind.
1 parent 2d555b1 commit 60e3c71

7 files changed

Lines changed: 59 additions & 19 deletions

File tree

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ authors:
2727
given-names: Frédérick
2828
orcid: "https://orcid.org/0000-0003-0959-2092"
2929
affiliation: "University of Bayreuth"
30-
version: "2.9.8"
30+
version: "2.9.9"
3131
date-released: "2026-08-07"
3232
license: GPL-3.0-or-later
3333
repository-code: "https://github.com/fmadore/IWAC-theme"

config/theme.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[info]
22
name = "IWAC Theme"
3-
version = "2.9.8"
3+
version = "2.9.9"
44
author = "Frédérick Madore"
55
description = "Islam West Africa Collection Theme - A customized Omeka S theme for the IWAC digital collection at ZMO Berlin. Features light/dark mode toggle and multilingual support."
66
theme_link = "https://github.com/fmadore/IWAC-theme"

language/fr.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgstr "Tout"
4444
msgid "An error occurred while processing your request. Please try again later."
4545
msgstr "Une erreur s’est produite lors du traitement de votre demande. Veuillez réessayer plus tard."
4646

47-
#: view/common/resource-page-block-layout/web-archive.phtml:33
47+
#: view/common/resource-page-block-layout/web-archive.phtml:60
4848
msgid "Archived web page"
4949
msgid_plural "Archived web pages"
5050
msgstr[0] "Page web archivée"

language/template.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ msgstr ""
4646
msgid "An error occurred while processing your request. Please try again later."
4747
msgstr ""
4848

49-
#: view/common/resource-page-block-layout/web-archive.phtml:33
49+
#: view/common/resource-page-block-layout/web-archive.phtml:60
5050
msgid "Archived web page"
5151
msgid_plural "Archived web pages"
5252
msgstr[0] ""

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iwac-theme",
3-
"version": "2.9.8",
3+
"version": "2.9.9",
44
"description": "Islam West Africa Collection Theme - A customized Omeka S theme for the IWAC digital collection.",
55
"main": "gulpfile.js",
66
"scripts": {

view/common/resource-page-block-layout/web-archive.phtml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
<?php
22
/**
3-
* Web archive block — renders the WebArchive module's ReplayWeb.page player for
4-
* any web-archive media on this item.
3+
* Web archive block — renders the ReplayWeb.page player for any web-archive
4+
* media on this item, and nothing at all when there is no capture, so the block
5+
* can sit in the default stack without leaving an empty heading everywhere.
56
*
6-
* Renders nothing when the item carries no capture, so the block can sit in the
7-
* default stack without leaving an empty heading on every other item.
7+
* This emits <replay-web-page> directly rather than calling $media->render(),
8+
* because the WebArchive module's own template sets neither of the two
9+
* attributes below and offers no way to pass them:
810
*
9-
* Web-archive media are deliberately excluded from `media-embeds.phtml` so the
10-
* two blocks can never both mount a player: two ReplayWeb.page instances over
11-
* one .wacz means two service-worker clients and twice the range traffic. The
12-
* corollary is that a site which does not enable this block (Admin → Themes →
13-
* Configure resource pages) will not render captures at all.
11+
* sandbox The player only sandboxes its iframe when this is set, and
12+
* the sandbox list it applies omits allow-top-navigation.
13+
* Without it, any archived page carrying a frame-buster (ad
14+
* scripts, addthis, old social widgets — common in the press
15+
* sites we capture) navigates the whole tab away mid-replay.
16+
* newWindowBase Sets baseUrlSourcePrefix, which the player otherwise
17+
* defaults to "https://replayweb.page/". That is where such a
18+
* navigation lands: a third-party origin that has no copy of
19+
* the collection, 404s its own API, then fails to load our
20+
* .wacz cross-origin and shows "Unexpected Loading Error".
21+
* Pointing it at our own shell keeps any escape same-origin.
22+
*
23+
* Trade-off: bypassing the module renderer also bypasses its assertPlayable()
24+
* guard, which refuses to render when the file is served with Content-Encoding.
25+
* Range requests are what the player actually uses and those are never
26+
* compressed, so this is acceptable — but if playback breaks after a server
27+
* change, check for Content-Encoding on the .wacz first.
28+
*
29+
* Web-archive media are excluded from media-embeds.phtml so the two blocks can
30+
* never both mount a player over the same file. A site that does not enable
31+
* this block (Admin → Themes → Configure resource pages) renders no captures.
1432
*
1533
* @var \Laminas\View\Renderer\PhpRenderer $this
1634
* @var \Omeka\Api\Representation\ItemRepresentation $resource
@@ -25,16 +43,38 @@ foreach ($resource->media() as $media) {
2543
$archives[] = $media;
2644
}
2745
}
46+
47+
if (!$archives):
48+
return;
49+
endif;
50+
51+
// No version query on the base: it is a directory the player's service worker
52+
// serves the app shell from, not a file.
53+
$replayBase = $this->assetUrl('vendor/replaywebpage/', 'WebArchive', false, false);
54+
$this->headLink()->appendStylesheet($this->assetUrl('css/web-archive.css', 'WebArchive'));
55+
$this->headScript()->appendFile($this->assetUrl('vendor/replaywebpage/ui.js', 'WebArchive'));
2856
?>
29-
<?php if ($archives): ?>
3057
<div id="web-archive" class="web-archive">
3158
<div class="web-archive__header">
3259
<h3 class="web-archive__heading">
3360
<?php echo $this->translatePlural('Archived web page', 'Archived web pages', count($archives)); ?>
3461
</h3>
3562
</div>
3663
<?php foreach ($archives as $media): ?>
37-
<?php echo $media->render(); ?>
64+
<?php
65+
$mediaData = $media->mediaData() ?? [];
66+
$startUrl = $mediaData['start_url'] ?? null;
67+
// Same fallback order as the module's renderer: per-media, then site-wide.
68+
$embedMode = $mediaData['embed_mode'] ?? $this->setting('webarchive_embed_mode', 'default');
69+
?>
70+
<replay-web-page
71+
source="<?php echo $this->escapeHtmlAttr($media->originalUrl()); ?>"
72+
replayBase="<?php echo $this->escapeHtmlAttr($replayBase); ?>"
73+
newWindowBase="<?php echo $this->escapeHtmlAttr($replayBase); ?>"
74+
sandbox
75+
<?php if ($startUrl): ?>url="<?php echo $this->escapeHtmlAttr($startUrl); ?>"<?php endif; ?>
76+
embed="<?php echo $this->escapeHtmlAttr($embedMode); ?>"
77+
style="width:100%;height:600px;display:block;">
78+
</replay-web-page>
3879
<?php endforeach; ?>
3980
</div>
40-
<?php endif; ?>

0 commit comments

Comments
 (0)