From 1602377834149c8d37fd0c25c82cbeca799a269e Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 9 Dec 2018 21:30:33 +0000 Subject: [PATCH] Support assets with apostrophe in filename Former-commit-id: a366c856a1ced2c71899f6b2fe68c210af3856f6 [formerly d3bfeb2c2311bef72d26dbf5c78b358305e51e00] Former-commit-id: 1892d83fc3251335bda90af659765ea0a31260a4 --- www/js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index cb858568..d35eba21 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1983,7 +1983,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module' // matches ZIM URLs with namespaces [-IJ] ('-' = metadata or 'I'/'J' = image). When the regex is used below, it will also // remove any relative or absolute path from ZIM-style URLs. // DEV: If you want to support more namespaces, add them to the END of the character set [-IJ] (not to the beginning) - var regexpTagsWithZimUrl = /(<(?:img|script|link|video|audio|source|track)\b[^>]*?\s)(?:src|href)\s*=\s*["'](?:\.\.\/|\/)+([-IJ]\/[^"']*)["']/ig; + var regexpTagsWithZimUrl = /(<(?:img|script|link|video|audio|source|track)\b[^>]*?\s)(?:src|href)(\s*=\s*["'])(?:\.\.\/|\/)+(?=[-IJ]\/)/ig; // DEV: The regex below matches ZIM links (anchor hrefs) that should have the html5 "donwnload" attribute added to // the link. This is currently the case for epub files in Project Gutenberg ZIMs -- add any further types you need @@ -2021,7 +2021,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module' function displayArticleInForm(dirEntry, htmlArticle) { // Replaces ZIM-style URLs of img, script, link and media tags with a data-kiwixurl to prevent 404 errors [kiwix-js #272 #376] // This replacement also processes the URL to remove the path so that the URL is ready for subsequent jQuery functions - htmlArticle = htmlArticle.replace(regexpTagsWithZimUrl, '$1data-kiwixurl="$2"'); + htmlArticle = htmlArticle.replace(regexpTagsWithZimUrl, '$1data-kiwixurl$2'); // Remove any empty media containers on page htmlArticle = htmlArticle.replace(/(<(audio|video)\b(?:[^<]|<(?!\/\2))+<\/\2>)/ig, function (p0) { return /(?:src|data-kiwixurl)\s*=\s*["']/.test(p0) ? p0 : '';