Bugzilla – Attachment 160242 Details for
Bug 35640
Upgrade FileSaver JS library to v2.0.4
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35640: Upgrade FileSaver JS library to v2.0.4
Bug-35640-Upgrade-FileSaver-JS-library-to-v204.patch (text/plain), 13.28 KB, created by
Owen Leonard
on 2023-12-22 13:40:53 UTC
(
hide
)
Description:
Bug 35640: Upgrade FileSaver JS library to v2.0.4
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2023-12-22 13:40:53 UTC
Size:
13.28 KB
patch
obsolete
>From 64e68f8f6401eeeec390d27043cdc30f44ad820b Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 22 Dec 2023 13:19:15 +0000 >Subject: [PATCH] Bug 35640: Upgrade FileSaver JS library to v2.0.4 > >This patch upgrades filesaver.js from an unknown version added in 2015 >to v2.0.4 which was released in 2020. The patch also moves the asset to >its own directory for consistency's sake. > >To test, apply the patch and clear your browser cache if necessary. > >- Locate a bibliographic record in the staff interface and edit it. >- Switch to the advanced editor. >- Click the dropdown menu next to the "Save to catalog" button, and test > both the "Save as MARC" and "Save as MARCXML" controls. >- In both cases the record should be downloaded correctly. >--- > koha-tmpl/intranet-tmpl/lib/filesaver.js | 232 ------------------ > .../lib/filesaver/FileSaver.min.js | 3 + > .../prog/en/includes/cateditor-ui.inc | 2 +- > .../intranet-tmpl/prog/en/modules/about.tt | 2 +- > 4 files changed, 5 insertions(+), 234 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/lib/filesaver.js > create mode 100644 koha-tmpl/intranet-tmpl/lib/filesaver/FileSaver.min.js > >diff --git a/koha-tmpl/intranet-tmpl/lib/filesaver.js b/koha-tmpl/intranet-tmpl/lib/filesaver.js >deleted file mode 100644 >index 378a9dcc41..0000000000 >--- a/koha-tmpl/intranet-tmpl/lib/filesaver.js >+++ /dev/null >@@ -1,232 +0,0 @@ >-/* FileSaver.js >- * A saveAs() FileSaver implementation. >- * 2013-10-21 >- * >- * By Eli Grey, http://eligrey.com >- * License: X11/MIT >- * See LICENSE.md >- */ >- >-/*global self */ >-/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true, >- plusplus: true */ >- >-/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ >- >-var saveAs = saveAs >- || (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator)) >- || (function(view) { >- "use strict"; >- var >- doc = view.document >- // only get URL when necessary in case BlobBuilder.js hasn't overridden it yet >- , get_URL = function() { >- return view.URL || view.webkitURL || view; >- } >- , URL = view.URL || view.webkitURL || view >- , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") >- , can_use_save_link = !view.externalHost && "download" in save_link >- , click = function(node) { >- var event = doc.createEvent("MouseEvents"); >- event.initMouseEvent( >- "click", true, false, view, 0, 0, 0, 0, 0 >- , false, false, false, false, 0, null >- ); >- node.dispatchEvent(event); >- } >- , webkit_req_fs = view.webkitRequestFileSystem >- , req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem >- , throw_outside = function (ex) { >- (view.setImmediate || view.setTimeout)(function() { >- throw ex; >- }, 0); >- } >- , force_saveable_type = "application/octet-stream" >- , fs_min_size = 0 >- , deletion_queue = [] >- , process_deletion_queue = function() { >- var i = deletion_queue.length; >- while (i--) { >- var file = deletion_queue[i]; >- if (typeof file === "string") { // file is an object URL >- URL.revokeObjectURL(file); >- } else { // file is a File >- file.remove(); >- } >- } >- deletion_queue.length = 0; // clear queue >- } >- , dispatch = function(filesaver, event_types, event) { >- event_types = [].concat(event_types); >- var i = event_types.length; >- while (i--) { >- var listener = filesaver["on" + event_types[i]]; >- if (typeof listener === "function") { >- try { >- listener.call(filesaver, event || filesaver); >- } catch (ex) { >- throw_outside(ex); >- } >- } >- } >- } >- , FileSaver = function(blob, name) { >- // First try a.download, then web filesystem, then object URLs >- var >- filesaver = this >- , type = blob.type >- , blob_changed = false >- , object_url >- , target_view >- , get_object_url = function() { >- var object_url = get_URL().createObjectURL(blob); >- deletion_queue.push(object_url); >- return object_url; >- } >- , dispatch_all = function() { >- dispatch(filesaver, "writestart progress write writeend".split(" ")); >- } >- // on any filesys errors revert to saving with object URLs >- , fs_error = function() { >- // don't create more object URLs than needed >- if (blob_changed || !object_url) { >- object_url = get_object_url(blob); >- } >- if (target_view) { >- target_view.location.href = object_url; >- } else { >- window.open(object_url, "_blank"); >- } >- filesaver.readyState = filesaver.DONE; >- dispatch_all(); >- } >- , abortable = function(func) { >- return function() { >- if (filesaver.readyState !== filesaver.DONE) { >- return func.apply(this, arguments); >- } >- }; >- } >- , create_if_not_found = {create: true, exclusive: false} >- , slice >- ; >- filesaver.readyState = filesaver.INIT; >- if (!name) { >- name = "download"; >- } >- if (can_use_save_link) { >- object_url = get_object_url(blob); >- // FF for Android has a nasty garbage collection mechanism >- // that turns all objects that are not pure javascript into 'deadObject' >- // this means `doc` and `save_link` are unusable and need to be recreated >- // `view` is usable though: >- doc = view.document; >- save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a"); >- save_link.href = object_url; >- save_link.download = name; >- var event = doc.createEvent("MouseEvents"); >- event.initMouseEvent( >- "click", true, false, view, 0, 0, 0, 0, 0 >- , false, false, false, false, 0, null >- ); >- save_link.dispatchEvent(event); >- filesaver.readyState = filesaver.DONE; >- dispatch_all(); >- return; >- } >- // Object and web filesystem URLs have a problem saving in Google Chrome when >- // viewed in a tab, so I force save with application/octet-stream >- // http://code.google.com/p/chromium/issues/detail?id=91158 >- if (view.chrome && type && type !== force_saveable_type) { >- slice = blob.slice || blob.webkitSlice; >- blob = slice.call(blob, 0, blob.size, force_saveable_type); >- blob_changed = true; >- } >- // Since I can't be sure that the guessed media type will trigger a download >- // in WebKit, I append .download to the filename. >- // https://bugs.webkit.org/show_bug.cgi?id=65440 >- if (webkit_req_fs && name !== "download") { >- name += ".download"; >- } >- if (type === force_saveable_type || webkit_req_fs) { >- target_view = view; >- } >- if (!req_fs) { >- fs_error(); >- return; >- } >- fs_min_size += blob.size; >- req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) { >- fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) { >- var save = function() { >- dir.getFile(name, create_if_not_found, abortable(function(file) { >- file.createWriter(abortable(function(writer) { >- writer.onwriteend = function(event) { >- target_view.location.href = file.toURL(); >- deletion_queue.push(file); >- filesaver.readyState = filesaver.DONE; >- dispatch(filesaver, "writeend", event); >- }; >- writer.onerror = function() { >- var error = writer.error; >- if (error.code !== error.ABORT_ERR) { >- fs_error(); >- } >- }; >- "writestart progress write abort".split(" ").forEach(function(event) { >- writer["on" + event] = filesaver["on" + event]; >- }); >- writer.write(blob); >- filesaver.abort = function() { >- writer.abort(); >- filesaver.readyState = filesaver.DONE; >- }; >- filesaver.readyState = filesaver.WRITING; >- }), fs_error); >- }), fs_error); >- }; >- dir.getFile(name, {create: false}, abortable(function(file) { >- // delete file if it already exists >- file.remove(); >- save(); >- }), abortable(function(ex) { >- if (ex.code === ex.NOT_FOUND_ERR) { >- save(); >- } else { >- fs_error(); >- } >- })); >- }), fs_error); >- }), fs_error); >- } >- , FS_proto = FileSaver.prototype >- , saveAs = function(blob, name) { >- return new FileSaver(blob, name); >- } >- ; >- FS_proto.abort = function() { >- var filesaver = this; >- filesaver.readyState = filesaver.DONE; >- dispatch(filesaver, "abort"); >- }; >- FS_proto.readyState = FS_proto.INIT = 0; >- FS_proto.WRITING = 1; >- FS_proto.DONE = 2; >- >- FS_proto.error = >- FS_proto.onwritestart = >- FS_proto.onprogress = >- FS_proto.onwrite = >- FS_proto.onabort = >- FS_proto.onerror = >- FS_proto.onwriteend = >- null; >- >- view.addEventListener("unload", process_deletion_queue, false); >- return saveAs; >-}(this.self || this.window || this.content)); >-// `self` is undefined in Firefox for Android content script context >-// while `this` is nsIContentFrameMessageManager >-// with an attribute `content` that corresponds to the window >- >-if (typeof module !== 'undefined') module.exports = saveAs; >diff --git a/koha-tmpl/intranet-tmpl/lib/filesaver/FileSaver.min.js b/koha-tmpl/intranet-tmpl/lib/filesaver/FileSaver.min.js >new file mode 100644 >index 0000000000..6d493b298c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/filesaver/FileSaver.min.js >@@ -0,0 +1,3 @@ >+(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error("could not download file")},d.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null},k.readAsDataURL(b)}else{var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m)},4E4)}});f.saveAs=g.saveAs=g,"undefined"!=typeof module&&(module.exports=g)}); >+ >+//# sourceMappingURL=FileSaver.min.js.map >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index 2ff15873b0..8f709215cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -1,7 +1,7 @@ > [% USE raw %] > [% USE Koha %] > [% Asset.js("lib/codemirror/codemirror.min.js") | $raw %] >-[% Asset.js("lib/filesaver.js") | $raw %] >+[% Asset.js("lib/filesaver/FileSaver.min.js") | $raw %] > [% Asset.css("lib/keyboard/css/keyboard.min.css") | $raw %] > [% Asset.js("lib/keyboard/js/jquery.keyboard.js") | $raw %] > [% Asset.js("lib/keyboard/languages/all.min.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >index 0f158fda91..c5ee7452c8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >@@ -1010,7 +1010,7 @@ > > <h2>FileSaver.js</h2> > <p> >- <a href="https://github.com/eligrey/FileSaver.js">FileSaver.js</a>: <a href="https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md">MIT License</p> >+ <a href="https://github.com/eligrey/FileSaver.js">FileSaver.js v2.0.4</a>: <a href="https://github.com/eligrey/FileSaver.js/blob/v2.0.4/LICENSE.md">MIT License</p> > > <h2>Flatpicker</h2> > <p> >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35640
:
160242
|
160381
|
160933