From 38b3b4ad764060af17acea646c5627c065afdceb Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 4 Jun 2024 14:40:16 -0400 Subject: [PATCH 01/14] handle prohibited chars in file names --- src/js/fileupload2.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 6f563d1..0d99a4d 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -188,6 +188,10 @@ function initSpanTxt(htmlId, key) { function addMessage(type, key) { $('#messages').html('').append($('
').addClass(type).text(getLocalizedString(dvLocale, key))); } +function appendMessage(type, text) { + $('#messages').append($('
').addClass(type).text(text)); +} + async function populatePageMetadata(data) { var mdFields = data.metadataBlocks.citation.fields; var title = ""; @@ -686,8 +690,18 @@ function queueFileForDirectUpload(file) { if (!send) { row.addClass('file-exists'); } - row.append($('').prop('type', 'checkbox').prop('id', 'file_' + fileBlock.children().length).prop('checked', send)) - .append($('
').addClass('ui-fileupload-filename').text(path)) + let badChars = !(fUpload.file.name.match(/[[\/:*?|;#]/)===null); + if(badChars) { + if($('.warn').length==0) { + appendMessage('warn','The highlighted file(s) below contain one or more disallowed characters (/;:|?*#) in their filename. Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.'); + } + } + row.append($('').prop('type', 'checkbox').prop('id', 'file_' + fileBlock.children().length).prop('checked', send)); + let fnameElement = $('
').addClass('ui-fileupload-filename').text(path); + if(badChars) { + fnameElement.addClass('badchars'); + } + row.append(fnameElement) .append($('
').text(file.size)).append($('
').addClass('ui - fileupload - progress')) .append($('
').addClass('ui - fileupload - cancel')); console.log('adding click handler for file_' + fileBlock.children().length); @@ -824,7 +838,7 @@ async function directUploadFinished() { console.log(fup.file.webkitRelativePath + ' : ' + fup.storageId); let entry = {}; entry.storageIdentifier = fup.storageId; - entry.fileName = fup.file.name; + entry.fileName = fup.file.name.replace(/[\/:*?|;#]/g,'_'); let path = fup.file.webkitRelativePath; console.log(path); path = path.substring(path.indexOf('/'), path.lastIndexOf('/')); From 42711ab3277681e4f9d1a0fa5195998bd561f261 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 4 Jun 2024 15:11:23 -0400 Subject: [PATCH 02/14] css for bad chars warning --- src/css/dvwebloader.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/css/dvwebloader.css b/src/css/dvwebloader.css index a413c03..f76292a 100644 --- a/src/css/dvwebloader.css +++ b/src/css/dvwebloader.css @@ -45,6 +45,10 @@ label { background-color: beige; padding: 10px; } +.warn { + background-color: bisque; + padding: 10px; +} .file-exists { background-color: lightblue; } @@ -67,3 +71,7 @@ h1 { width: 58%; display:inline-block; } +.badchars { + background-color: bisque; + padding: 10px; +} From 3c6af7d9de73d91a5c21c649883e6f29d7df4500 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 4 Jun 2024 16:06:41 -0400 Subject: [PATCH 03/14] i18n re: badChars --- src/js/lang.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/lang.js b/src/js/lang.js index c6ea7ba..c0f94d9 100644 --- a/src/js/lang.js +++ b/src/js/lang.js @@ -15,6 +15,7 @@ const translations = { msgNoFile: "No files to upload. Check some files, or refresh to start over.", msgUploadCompleteRegistering: "Uploads to S3 complete. Now registering all files with the dataset. This may take some time for large numbers of files.", msgUploadComplete: "Upload complete, all files in dataset. Close this window and refresh your dataset page to see the uploaded files.", + msgRequiredFileNameChange: "The highlighted file(s) below contain one or more disallowed characters (/;:|?*#) in their filename. Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", }, fr: { title: "Envoi d'un dossier", @@ -31,6 +32,7 @@ const translations = { msgNoFile: "Aucun fichier à envoyer. Cochez certains fichiers ou rafraîchissez la page pour recommencer.", msgUploadCompleteRegistering: "Envois vers S3 terminés. Enregistrement de tous les fichiers en cours dans le jeu de données. Cela peut prendre du temps pour un grand nombre de fichiers.", msgUploadComplete: "Envoi terminé, tous les fichiers sont dans le jeu de données. Fermez cette fenêtre et rafraîchissez la page de votre jeu de données pour voir les fichiers envoyés.", + msgRequiredFileNameChange: "Le ou les fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (/;:|?*#) dans leur nom de fichier. Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", }, }; From c4d8539acac8b46669afc188e88b6d42a86cd725 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 12:59:23 -0400 Subject: [PATCH 04/14] check for bad paths, munge path/filename before comparing with existing --- src/js/fileupload2.js | 19 +++++++++++++++++-- src/js/lang.js | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 0d99a4d..3299b83 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -667,8 +667,20 @@ function queueFileForDirectUpload(file) { } var fUpload = new fileUpload(file); let send = true; - let path = file.webkitRelativePath.substring(file.webkitRelativePath.indexOf('/') + 1); + let origPath = file.webkitRelativePath.substring(file.webkitRelativePath.indexOf('/') + 1); console.log(path); + let path =origPath.substring(0, origPath.length - file.name.length); + let badPath = (path.match(/^[a-zA-Z0-9_\-.\\\/ ]*$/)===null); + if(badPath) { + if($('.warn').length==0) { + addMessage('warn', 'msgRequiredFileOrPathNameChange'); + } + //Munge path according to rules + path = path.replace(/[^\w\d_\\.\\\/ ]+/g,'_'); + //Munge filename if needed + path=path.concat(file.name.replace(/[\/:*?|;#]/g,'_')); + } + //Now check versus existing files if (path in existingFiles) { send = false; } else if (removeExtension(path) in convertedFileNameMap) { @@ -697,7 +709,7 @@ function queueFileForDirectUpload(file) { } } row.append($('').prop('type', 'checkbox').prop('id', 'file_' + fileBlock.children().length).prop('checked', send)); - let fnameElement = $('
').addClass('ui-fileupload-filename').text(path); + let fnameElement = $('
').addClass('ui-fileupload-filename').text(origPath); if(badChars) { fnameElement.addClass('badchars'); } @@ -838,10 +850,13 @@ async function directUploadFinished() { console.log(fup.file.webkitRelativePath + ' : ' + fup.storageId); let entry = {}; entry.storageIdentifier = fup.storageId; + //Remove bad file name chars entry.fileName = fup.file.name.replace(/[\/:*?|;#]/g,'_'); let path = fup.file.webkitRelativePath; console.log(path); path = path.substring(path.indexOf('/'), path.lastIndexOf('/')); + //Remove bad path chars + path = path.replace(/[^\w\d_\\.\\\/ ]+/g,'_'); if (path.length !== 0) { entry.directoryLabel = path; } diff --git a/src/js/lang.js b/src/js/lang.js index c0f94d9..fb0ef63 100644 --- a/src/js/lang.js +++ b/src/js/lang.js @@ -15,7 +15,7 @@ const translations = { msgNoFile: "No files to upload. Check some files, or refresh to start over.", msgUploadCompleteRegistering: "Uploads to S3 complete. Now registering all files with the dataset. This may take some time for large numbers of files.", msgUploadComplete: "Upload complete, all files in dataset. Close this window and refresh your dataset page to see the uploaded files.", - msgRequiredFileNameChange: "The highlighted file(s) below contain one or more disallowed characters (/;:|?*#) in their filename. Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", + msgRequiredPatOrFileNameChange: "The highlighted path/file(s) below contain one or more disallowed characters (paths can only contain a-Z, 0-9, '_', '-', '.', '\', '/' and ' ', and filenames cannot contain any of /;:|?*#). Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", }, fr: { title: "Envoi d'un dossier", @@ -32,7 +32,7 @@ const translations = { msgNoFile: "Aucun fichier à envoyer. Cochez certains fichiers ou rafraîchissez la page pour recommencer.", msgUploadCompleteRegistering: "Envois vers S3 terminés. Enregistrement de tous les fichiers en cours dans le jeu de données. Cela peut prendre du temps pour un grand nombre de fichiers.", msgUploadComplete: "Envoi terminé, tous les fichiers sont dans le jeu de données. Fermez cette fenêtre et rafraîchissez la page de votre jeu de données pour voir les fichiers envoyés.", - msgRequiredFileNameChange: "Le ou les fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (/;:|?*#) dans leur nom de fichier. Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", + msgRequiredFileNameChange: "Les chemins/noms de fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (les chemins ne peuvent contenir que a-Z, 0-9, '_', '-', '.', '\', '/' et ' ', et les noms de fichiers ne peuvent contenir aucun des éléments suivants : /;:|?*#). Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", }, }; From ee691b748c1fd5fa0898c0ce9a6f75b49f019f12 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:04:51 -0400 Subject: [PATCH 05/14] fix path munging in good case --- src/js/fileupload2.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 3299b83..2e38b4c 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -668,7 +668,8 @@ function queueFileForDirectUpload(file) { var fUpload = new fileUpload(file); let send = true; let origPath = file.webkitRelativePath.substring(file.webkitRelativePath.indexOf('/') + 1); - console.log(path); + console.log("Original Path: " + origPath); + //Remove filename part let path =origPath.substring(0, origPath.length - file.name.length); let badPath = (path.match(/^[a-zA-Z0-9_\-.\\\/ ]*$/)===null); if(badPath) { @@ -677,9 +678,10 @@ function queueFileForDirectUpload(file) { } //Munge path according to rules path = path.replace(/[^\w\d_\\.\\\/ ]+/g,'_'); - //Munge filename if needed - path=path.concat(file.name.replace(/[\/:*?|;#]/g,'_')); } + //Re-Add filename, munge filename if needed + path=path.concat(file.name.replace(/[\/:*?|;#]/g,'_')); + console.log("Final Path: " + path); //Now check versus existing files if (path in existingFiles) { send = false; From ff76b80485f1e31ab24751cd739c67c27799c4ce Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:06:51 -0400 Subject: [PATCH 06/14] i18n fix --- src/js/fileupload2.js | 7 ++----- src/js/lang.js | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 2e38b4c..f15f9bf 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -188,9 +188,6 @@ function initSpanTxt(htmlId, key) { function addMessage(type, key) { $('#messages').html('').append($('
').addClass(type).text(getLocalizedString(dvLocale, key))); } -function appendMessage(type, text) { - $('#messages').append($('
').addClass(type).text(text)); -} async function populatePageMetadata(data) { var mdFields = data.metadataBlocks.citation.fields; @@ -674,7 +671,7 @@ function queueFileForDirectUpload(file) { let badPath = (path.match(/^[a-zA-Z0-9_\-.\\\/ ]*$/)===null); if(badPath) { if($('.warn').length==0) { - addMessage('warn', 'msgRequiredFileOrPathNameChange'); + addMessage('warn', 'msgRequiredPathOrFileNameChange'); } //Munge path according to rules path = path.replace(/[^\w\d_\\.\\\/ ]+/g,'_'); @@ -707,7 +704,7 @@ function queueFileForDirectUpload(file) { let badChars = !(fUpload.file.name.match(/[[\/:*?|;#]/)===null); if(badChars) { if($('.warn').length==0) { - appendMessage('warn','The highlighted file(s) below contain one or more disallowed characters (/;:|?*#) in their filename. Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.'); + addMessage('warn', 'msgRequiredPathOrFileNameChange'); } } row.append($('').prop('type', 'checkbox').prop('id', 'file_' + fileBlock.children().length).prop('checked', send)); diff --git a/src/js/lang.js b/src/js/lang.js index fb0ef63..7dccdeb 100644 --- a/src/js/lang.js +++ b/src/js/lang.js @@ -15,7 +15,7 @@ const translations = { msgNoFile: "No files to upload. Check some files, or refresh to start over.", msgUploadCompleteRegistering: "Uploads to S3 complete. Now registering all files with the dataset. This may take some time for large numbers of files.", msgUploadComplete: "Upload complete, all files in dataset. Close this window and refresh your dataset page to see the uploaded files.", - msgRequiredPatOrFileNameChange: "The highlighted path/file(s) below contain one or more disallowed characters (paths can only contain a-Z, 0-9, '_', '-', '.', '\', '/' and ' ', and filenames cannot contain any of /;:|?*#). Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", + msgRequiredPathOrFileNameChange: "The highlighted path/file(s) below contain one or more disallowed characters (paths can only contain a-Z, 0-9, '_', '-', '.', '\', '/' and ' ', and filenames cannot contain any of /;:|?*#). Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", }, fr: { title: "Envoi d'un dossier", @@ -32,7 +32,7 @@ const translations = { msgNoFile: "Aucun fichier à envoyer. Cochez certains fichiers ou rafraîchissez la page pour recommencer.", msgUploadCompleteRegistering: "Envois vers S3 terminés. Enregistrement de tous les fichiers en cours dans le jeu de données. Cela peut prendre du temps pour un grand nombre de fichiers.", msgUploadComplete: "Envoi terminé, tous les fichiers sont dans le jeu de données. Fermez cette fenêtre et rafraîchissez la page de votre jeu de données pour voir les fichiers envoyés.", - msgRequiredFileNameChange: "Les chemins/noms de fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (les chemins ne peuvent contenir que a-Z, 0-9, '_', '-', '.', '\', '/' et ' ', et les noms de fichiers ne peuvent contenir aucun des éléments suivants : /;:|?*#). Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", + msgRequiredPathOrFileNameChange: "Les chemins/noms de fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (les chemins ne peuvent contenir que a-Z, 0-9, '_', '-', '.', '\', '/' et ' ', et les noms de fichiers ne peuvent contenir aucun des éléments suivants : /;:|?*#). Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", }, }; From f78fd4dd463f71a9ac2740e365031915914b71a4 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:10:12 -0400 Subject: [PATCH 07/14] fix regex --- src/js/fileupload2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index f15f9bf..82b3960 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -668,7 +668,7 @@ function queueFileForDirectUpload(file) { console.log("Original Path: " + origPath); //Remove filename part let path =origPath.substring(0, origPath.length - file.name.length); - let badPath = (path.match(/^[a-zA-Z0-9_\-.\\\/ ]*$/)===null); + let badPath = (path.match(/^[a-zA-Z0-9_\-\.\\\/ ]*$/)===null); if(badPath) { if($('.warn').length==0) { addMessage('warn', 'msgRequiredPathOrFileNameChange'); From 9bf81a9163200555e37e77476f422e1eff0fff3e Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:19:27 -0400 Subject: [PATCH 08/14] fix highlight, cleanup warning --- src/js/fileupload2.js | 4 ++-- src/js/lang.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 82b3960..ed91791 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -668,7 +668,7 @@ function queueFileForDirectUpload(file) { console.log("Original Path: " + origPath); //Remove filename part let path =origPath.substring(0, origPath.length - file.name.length); - let badPath = (path.match(/^[a-zA-Z0-9_\-\.\\\/ ]*$/)===null); + let badPath = (path.match(/^[\w\d_\-\.\\\/ ]*$/)===null); if(badPath) { if($('.warn').length==0) { addMessage('warn', 'msgRequiredPathOrFileNameChange'); @@ -709,7 +709,7 @@ function queueFileForDirectUpload(file) { } row.append($('').prop('type', 'checkbox').prop('id', 'file_' + fileBlock.children().length).prop('checked', send)); let fnameElement = $('
').addClass('ui-fileupload-filename').text(origPath); - if(badChars) { + if(badPath || badChars) { fnameElement.addClass('badchars'); } row.append(fnameElement) diff --git a/src/js/lang.js b/src/js/lang.js index 7dccdeb..4671bc8 100644 --- a/src/js/lang.js +++ b/src/js/lang.js @@ -15,7 +15,7 @@ const translations = { msgNoFile: "No files to upload. Check some files, or refresh to start over.", msgUploadCompleteRegistering: "Uploads to S3 complete. Now registering all files with the dataset. This may take some time for large numbers of files.", msgUploadComplete: "Upload complete, all files in dataset. Close this window and refresh your dataset page to see the uploaded files.", - msgRequiredPathOrFileNameChange: "The highlighted path/file(s) below contain one or more disallowed characters (paths can only contain a-Z, 0-9, '_', '-', '.', '\', '/' and ' ', and filenames cannot contain any of /;:|?*#). Disallowed characters will be replaced by an underscore (_) if the file(s) are uploaded.", + msgRequiredPathOrFileNameChange: "The highlighted path/file(s) below contain one or more disallowed characters (paths can only contain a-Z, 0-9, '_', '-', '.', '\', '/' and ' ', and filenames cannot contain any of '/;:|?*#' ). Disallowed characters will be replaced by an underscore ('_') if the file(s) are uploaded.", }, fr: { title: "Envoi d'un dossier", @@ -32,7 +32,7 @@ const translations = { msgNoFile: "Aucun fichier à envoyer. Cochez certains fichiers ou rafraîchissez la page pour recommencer.", msgUploadCompleteRegistering: "Envois vers S3 terminés. Enregistrement de tous les fichiers en cours dans le jeu de données. Cela peut prendre du temps pour un grand nombre de fichiers.", msgUploadComplete: "Envoi terminé, tous les fichiers sont dans le jeu de données. Fermez cette fenêtre et rafraîchissez la page de votre jeu de données pour voir les fichiers envoyés.", - msgRequiredPathOrFileNameChange: "Les chemins/noms de fichiers en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (les chemins ne peuvent contenir que a-Z, 0-9, '_', '-', '.', '\', '/' et ' ', et les noms de fichiers ne peuvent contenir aucun des éléments suivants : /;:|?*#). Les caractères non autorisés seront remplacés par un trait de soulignement (_) si le(s) fichier(s) sont téléchargés.", + msgRequiredPathOrFileNameChange: "Le(s) chemin(s) en surbrillance ci-dessous contiennent un ou plusieurs caractères non autorisés (les chemins ne peuvent contenir que a-Z, 0-9, '_', '-', '.', '\', '/' et ' ', et les noms de fichiers ne peuvent contenir aucun des éléments '/;:|?*#' ). Les caractères non autorisés seront remplacés par un trait de soulignement (« _ ») si le(s) fichier(s) sont téléchargés.", }, }; From 62336b4785309b8942a1191d164a6df2098e42eb Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:28:12 -0400 Subject: [PATCH 09/14] use origPath in rawFileMap --- src/js/fileupload2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index ed91791..01629bd 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -685,7 +685,7 @@ function queueFileForDirectUpload(file) { } else if (removeExtension(path) in convertedFileNameMap) { send = false; } - rawFileMap[path] = file; + rawFileMap[origPath] = file; let i = rawFileMap.length; //startUploads(); if (send) { From e385b7c4712a76b034c53b33270637f6c4029a27 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 4 Jun 2024 16:09:28 -0400 Subject: [PATCH 10/14] latest libraries --- src/dvwebloader.html | 4 ++-- src/js/fileupload2.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dvwebloader.html b/src/dvwebloader.html index 8e41d24..0ab0d52 100644 --- a/src/dvwebloader.html +++ b/src/dvwebloader.html @@ -3,8 +3,8 @@ Dataverse WebLoader - - + + diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 6f563d1..9095856 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -82,23 +82,23 @@ $(document).ready(function() { switch (checksumAlgName) { case 'MD5': - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/md5.js"; break; case 'SHA-1': - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/sha1.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/sha1.js"; break; case 'SHA-256': - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/sha256.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/sha256.js"; break; case 'SHA-512': - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/x64-core.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/x64-core.js"; head.appendChild(js); js = document.createElement("script"); js.type = "text/javascript"; - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/sha512.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/sha512.js"; break; default: - js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.js"; + js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/md5.js"; } head.appendChild(js); retrieveDatasetInfo(); From 21f03f80c2fbffb794b55d7f758a97b57e0a182e Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 4 Jun 2024 16:13:09 -0400 Subject: [PATCH 11/14] localinstall script --- localinstall.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 localinstall.sh diff --git a/localinstall.sh b/localinstall.sh new file mode 100644 index 0000000..ef8a47a --- /dev/null +++ b/localinstall.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +echo Creating version of DVWebloader that uses only local libraries +echo Run this script in the directory with the dvwebloader.html file + + +dirLocal=$(pwd) + +echo Downloading local copies of remote JavaScript libraries: +sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u | sed -n 's/^\(.*\/\)*\(.*\)/sed -i \x27s,\0\,lib\/\2,\x27 *.html/p' > replace_js.sh +sed -n 's/.*src="\(http[^"]*\)".*/\1/p' *.html | sort -u > urls_js.txt +source replace_js.sh +cat urls_js.txt + +echo Downloading local copies of remote JavaScript libraries referenced in js files: +cd ./js +sed -n 's/.*src[ ]*=[ ]*"\(http[^"]*\)".*/\1/p' *.js | sort -u | sed -n 's/^\(.*\/\)*\(.*\)/sed -i \x27s,\0\,lib\/\2,\x27 *.js/p' > replacejs_js.sh +sed -n 's/.*src[ ]*=[ ]*"\(http[^"]*\)".*/\1/p' *.js | sort -u > urlsjs_js.txt +source replacejs_js.sh +cat urlsjs_js.txt +cd .. + +echo Downloading local copies of remote CSS files: +sed -n 's/.* replace_css.sh +sed -n 's/.* urls_css.txt +source replace_css.sh +cat urls_css.txt + +if [ ! -d ./lib ]; then + mkdir ./lib +fi +cd ./lib +while read url; do + wget --quiet $url +done < "../urls_js.txt" +while read url; do + wget --quiet $url +done < "../js/urlsjs_js.txt" + + +cd ".." +if [ ! -d ./css ]; then + mkdir ./css +fi +cd ./css +while read url; do + wget --quiet $url +done < "../urls_css.txt" + +cd .. + + +echo Cleaning Up... +rm urls_js.txt +rm urls_css.txt +rm replace_js.sh +rm replace_css.sh +rm js/urlsjs_js.txt +rm js/replacejs_js.sh + +echo Done +exit 0 From 104e985d108ef9eefc6d40950fc08c374654e805 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:42:21 -0400 Subject: [PATCH 12/14] fix sha512 async issue --- src/js/fileupload2.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/fileupload2.js b/src/js/fileupload2.js index 6f563d1..502d698 100644 --- a/src/js/fileupload2.js +++ b/src/js/fileupload2.js @@ -92,10 +92,13 @@ $(document).ready(function() { break; case 'SHA-512': js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/x64-core.js"; + //Make async false to avoid sha512 loading before the x64-core which can cause an error + js.async = false; head.appendChild(js); js = document.createElement("script"); js.type = "text/javascript"; js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/sha512.js"; + js.async = false; break; default: js.src = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.js"; From 81b57d8c6c34c3812fa1198cd0242844d0a1605e Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Jun 2024 13:59:55 -0400 Subject: [PATCH 13/14] update version --- src/dvwebloader.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dvwebloader.html b/src/dvwebloader.html index 8e41d24..23a290d 100644 --- a/src/dvwebloader.html +++ b/src/dvwebloader.html @@ -26,7 +26,7 @@

Folder Upload

- DVWebloader v0.2 + DVWebloader v0.3