From 58eb0058598df0c082e902bc21c66b1a1a92058c Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 6 Feb 2021 18:03:03 +0000 Subject: [PATCH] Preliminary support for ZIMs with no namespace Former-commit-id: 48b08080315e614bc83232b38f7ad4635cf49028 [formerly 25819217876aea980a41ce62ea1f526d6ec8a5ce [formerly d7f4153def08652e4bc75f9a142d96a94c23f2d4]] Former-commit-id: 529a316522cf28e2752955fbac95eccee4759440 Former-commit-id: f34f63004066c50c216d7376a1e3fc0a93ed5329 --- pwabuilder-sw.js | 2 +- www/js/app.js | 38 ++++++++++++++++++++++++------------- www/js/lib/settingsStore.js | 2 +- www/js/lib/uiUtil.js | 6 +++--- www/js/lib/zimArchive.js | 38 +++++++++++++++++++++++++++++++------ www/js/lib/zimfile.js | 3 +++ 6 files changed, 65 insertions(+), 24 deletions(-) diff --git a/pwabuilder-sw.js b/pwabuilder-sw.js index 8e342f26..dd88e81e 100644 --- a/pwabuilder-sw.js +++ b/pwabuilder-sw.js @@ -12,7 +12,7 @@ const regexpKiwixDownloadLinks = /download\.kiwix\.org/i; // Pattern for ZIM file namespace - see https://wiki.openzim.org/wiki/ZIM_file_format#Namespaces // In our case, there is also the ZIM file name, used as a prefix in the URL -const regexpZIMUrlWithNamespace = /(?:^|\/)([^\/]+\/)([-ABIJMUVWX])\/(.+)/; +const regexpZIMUrlWithNamespace = /(?:^|\/)([^\/]+\/)([-ABCIJMUVWX])\/(.+)/; const CACHE = "kiwix-precache-" + appVersion; const precacheFiles = [ diff --git a/www/js/app.js b/www/js/app.js index 2ac126ca..ea003906 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -3075,14 +3075,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett // Pattern to find the path in a url var regexpPath = /^(.*\/)[^\/]+$/; // Pattern to find a ZIM URL (with its namespace) - see https://wiki.openzim.org/wiki/ZIM_file_format#Namespaces - var regexpZIMUrlWithNamespace = /^[.\/]*([-ABIJMUVWX]\/.+)$/; - // Regex below finds images, scripts, and stylesheets with ZIM-type metadata and image namespaces [kiwix-js #378] - // It first searches for ]*?\s)(?:src|href)(\s*=\s*["'])(?:\.\.\/|\/)+(?=[-IJ]\/)/ig; + var regexpZIMUrlWithNamespace = /^[./]*([-ABCIJMUVWX]\/.+)$/; + // Regex below finds images, scripts, stylesheets and tracks with ZIM-type metadata and image namespaces [kiwix-js #378]. + // It first searches for ]*?\s)(?:src|href)(\s*=\s*(["']))(?!http)(.+?)(?=\3|\?|#)/ig; // Regex below tests the html of an article for active content [kiwix-js #466] // It inspects every