mirror of
https://github.com/moodle/moodle.git
synced 2025-04-05 08:23:01 +02:00
MDL-65297 atto_managefiles: improve filename decoding.
Filenames containing # character would previously be missed.
This commit is contained in:
parent
7ec1804935
commit
8e7b3d4ede
@ -157,7 +157,7 @@ M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || {
|
||||
usedFiles = {};
|
||||
|
||||
while ((match = pattern.exec(content.get('innerHTML'))) !== null) {
|
||||
filename = decodeURI(match[1]);
|
||||
filename = decodeURIComponent(match[1]);
|
||||
usedFiles[filename] = true;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-atto_managefiles-usedfiles",function(e,t){var n={HASMISSINGFILES:"has-missing-files",HASUNUSEDFILES:"has-unused-files"},r={FILEANCESTOR:".fitem",FORM:"#atto_managefiles_manageform",MISSINGFILES:".missing-files"};M.atto_managefiles=M.atto_managefiles||{},M.atto_managefiles.usedfiles=M.atto_managefiles.usedfiles||{_usercontext:null,_itemid:null,_elementid:null,init:function(t){this._usercontext=t.usercontext,this._itemid=t.itemid,this._elementid=t.elementid;var i=t.files,s=e.one(r.FORM),o,u,a,f,l;if(!s||!window.parent)return;o=this._getUsedFiles(),u=this.findUnusedFiles(i,o),a=this.findMissingFiles(i,o),u.length>0?(s.all('input[type=checkbox][name^="deletefile"]').each(function(t){e.Array.indexOf(u,t.getData("filename"))===-1&&t.ancestor(r.FILEANCESTOR).remove()}),s.addClass(n.HASUNUSEDFILES)):s.removeClass(n.HASUNUSEDFILES);if(a.length>0){f="<ul>";for(l=0;l<a.length;l++)f+="<li>"+e.Escape.html(a[l])+"</li>";f+="</ul>",s.one(r.MISSINGFILES).setHTML("").append(f),s.addClass(n.HASMISSINGFILES)}else s.removeClass(n.HASMISSINGFILES)},_getUsedFiles:function(){var t=e.one(window.parent.document.getElementById(this._elementid+"editable")),n=M.cfg.wwwroot+"/draftfile.php/"+this._usercontext+"/user/draft/"+this._itemid+"/",r=new RegExp(n.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g,"\\$&")+"(.+?)[\\?\"']","gm"),i="",s="",o={};while((s=r.exec(t.get("innerHTML")))!==null)i=decodeURI(s[1]),o[i]=!0;return o},findUnusedFiles:function(e,t){var n,r=[];for(n in e)t[n]||r.push(n);return r},findMissingFiles:function(e,t){var n,r=[];for(n in t)e[n]||r.push(n);return r}}},"@VERSION@",{requires:["node","escape"]});
|
||||
YUI.add("moodle-atto_managefiles-usedfiles",function(e,t){var n={HASMISSINGFILES:"has-missing-files",HASUNUSEDFILES:"has-unused-files"},r={FILEANCESTOR:".fitem",FORM:"#atto_managefiles_manageform",MISSINGFILES:".missing-files"};M.atto_managefiles=M.atto_managefiles||{},M.atto_managefiles.usedfiles=M.atto_managefiles.usedfiles||{_usercontext:null,_itemid:null,_elementid:null,init:function(t){this._usercontext=t.usercontext,this._itemid=t.itemid,this._elementid=t.elementid;var i=t.files,s=e.one(r.FORM),o,u,a,f,l;if(!s||!window.parent)return;o=this._getUsedFiles(),u=this.findUnusedFiles(i,o),a=this.findMissingFiles(i,o),u.length>0?(s.all('input[type=checkbox][name^="deletefile"]').each(function(t){e.Array.indexOf(u,t.getData("filename"))===-1&&t.ancestor(r.FILEANCESTOR).remove()}),s.addClass(n.HASUNUSEDFILES)):s.removeClass(n.HASUNUSEDFILES);if(a.length>0){f="<ul>";for(l=0;l<a.length;l++)f+="<li>"+e.Escape.html(a[l])+"</li>";f+="</ul>",s.one(r.MISSINGFILES).setHTML("").append(f),s.addClass(n.HASMISSINGFILES)}else s.removeClass(n.HASMISSINGFILES)},_getUsedFiles:function(){var t=e.one(window.parent.document.getElementById(this._elementid+"editable")),n=M.cfg.wwwroot+"/draftfile.php/"+this._usercontext+"/user/draft/"+this._itemid+"/",r=new RegExp(n.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g,"\\$&")+"(.+?)[\\?\"']","gm"),i="",s="",o={};while((s=r.exec(t.get("innerHTML")))!==null)i=decodeURIComponent(s[1]),o[i]=!0;return o},findUnusedFiles:function(e,t){var n,r=[];for(n in e)t[n]||r.push(n);return r},findMissingFiles:function(e,t){var n,r=[];for(n in t)e[n]||r.push(n);return r}}},"@VERSION@",{requires:["node","escape"]});
|
||||
|
@ -156,7 +156,7 @@ M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || {
|
||||
usedFiles = {};
|
||||
|
||||
while ((match = pattern.exec(content.get('innerHTML'))) !== null) {
|
||||
filename = decodeURI(match[1]);
|
||||
filename = decodeURIComponent(match[1]);
|
||||
usedFiles[filename] = true;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ M.atto_managefiles.usedfiles = M.atto_managefiles.usedfiles || {
|
||||
usedFiles = {};
|
||||
|
||||
while ((match = pattern.exec(content.get('innerHTML'))) !== null) {
|
||||
filename = decodeURI(match[1]);
|
||||
filename = decodeURIComponent(match[1]);
|
||||
usedFiles[filename] = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user