From 813b365b5fda927a714dbae8e5f74f03a702c49a Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 4 Dec 2026 10:42:08 +0000 Subject: [PATCH] Add a fuzzy rule canonicalising the SCP wiki's alias hosts scp-wiki.wikidot.com, scpwiki.com, www.scpwiki.com and www.scp-wiki.net all serve the same wiki with HTTP 200 rather than a redirect, and pages link across them freely. Without canonicalisation the same article lands at several ZIM paths and cross-host links resolve to nothing: on a 10-page crawl, 30 escaped links whose target was in the ZIM under the canonical host, and SCP-4558's whole offset chain stored only under alias hosts. Driver: openzim/zim-requests#402. --- CHANGELOG.md | 4 ++++ rules/rules.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77dcde76..e606435e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `scp_alias_hosts` fuzzy rule canonicalising the SCP wiki's alias hosts (`scpwiki.com`, `www.scpwiki.com`, `www.scp-wiki.net`) onto `scp-wiki.wikidot.com` ; all of them serve the same wiki with HTTP 200 rather than a redirect, so without it the same article lands at several ZIM paths and cross-host links resolve to nothing (#423, openzim/zim-requests#402) + ## [5.6.0] - 2026-11-20 ### Added diff --git a/rules/rules.yaml b/rules/rules.yaml index 1d5e40aa..b60362c0 100644 --- a/rules/rules.yaml +++ b/rules/rules.yaml @@ -30,6 +30,49 @@ # `unreplace_pattern`, so `defuzzify()` correctly leaves its output unchanged instead of # guessing. fuzzyRules: + # --- SCP wiki (openzim/zim-requests#402) ------------------------------------- + # The English SCP wiki is served, identically and with HTTP 200 rather than a + # redirect, on several hostnames: scp-wiki.wikidot.com (canonical), scpwiki.com, + # www.scpwiki.com and www.scp-wiki.net. Pages link across them freely -- SCP-4558's + # own ListPages pager points at http://www.scp-wiki.net/scp-4558/offset/1 -- so + # without canonicalisation the same article lands at several ZIM paths and + # cross-host links resolve to nothing. Measured on a 10-page crawl: 30 broken + # links and SCP-4558's whole offset chain stored twice under alias hosts. + # + # Anchored with ^, unlike most rules here, because this rewrites the *host*. That is + # not hypothetical: sibling language branches live on subdomains of these very + # domains -- ko.scp-wiki.net, linked from other branches' pages -- and an unanchored + # match would rewrite them onto the English wiki, as well as any lookalike host. + # + # unreplace_pattern is the never-matching (?!): the forward rule cannot know which + # alias a canonical URL came from, and the overwhelming majority of + # scp-wiki.wikidot.com URLs were never aliased at all, so mapping them back to an + # alias would be wrong far more often than right. Leaving the canonical URL in + # place is both plausible and correct for the common case. + - name: scp_alias_hosts + pattern: ^(?:www\.)?(?:scpwiki\.com|scp-wiki\.net)/(.*) + replace: scp-wiki.wikidot.com/\1 + unreplace_pattern: (?!) + unreplace: "" + tests: + - raw_url: scpwiki.com/scp-173 + fuzzified_url: scp-wiki.wikidot.com/scp-173 + defuzzified_url: scp-wiki.wikidot.com/scp-173 + - raw_url: www.scpwiki.com/scp-173 + fuzzified_url: scp-wiki.wikidot.com/scp-173 + defuzzified_url: scp-wiki.wikidot.com/scp-173 + - raw_url: www.scp-wiki.net/scp-4558/offset/1 + fuzzified_url: scp-wiki.wikidot.com/scp-4558/offset/1 + defuzzified_url: scp-wiki.wikidot.com/scp-4558/offset/1 + - raw_url: scp-wiki.wikidot.com/scp-173 + unchanged: true # already canonical + - raw_url: evil-scpwiki.com/scp-173 + unchanged: true # anchored, so a lookalike host is not rewritten + - raw_url: ko.scp-wiki.net/scp-173 + unchanged: true # a sibling language branch lives on a subdomain of an alias + - raw_url: scp-wiki.wdfiles.com/local--files/scp-173/x.png + unchanged: true # the file store is a different host and stays as it is + - name: googlevideo_com pattern: .*googlevideo.com/(videoplayback(?=\?)).*[?&](id=[^&]+).* replace: youtube.fuzzy.replayweb.page/\1?\2