Skip to content

Commit

Permalink
Merge hotfix for issue #2235 into develop
Browse files Browse the repository at this point in the history
Already merged into main.
  • Loading branch information
robyngit committed Dec 19, 2023
2 parents 90bd6fe + 758ff8e commit fd3027d
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MetacatUI is an open source, community project. We [welcome contributions](http

Cite this software as:

> Matthew B. Jones, Chris Jones, Lauren Walker, Robyn Thiessen-Bock, Ben Leinfelder, Peter Slaughter, Bryce Mecum, Rushiraj Nenuji, Hesham Elbashandy, Val Hendrix. 2022. MetacatUI: A client-side web interface for DataONE data repositories (version 2.27.0). Arctic Data Center. [doi:10.18739/A25M6282K](https://doi.org/10.18739/A25M6282K)
> Matthew B. Jones, Chris Jones, Lauren Walker, Robyn Thiessen-Bock, Ben Leinfelder, Peter Slaughter, Bryce Mecum, Rushiraj Nenuji, Hesham Elbashandy, Val Hendrix. 2023. MetacatUI: A client-side web interface for DataONE data repositories (version 2.27.1). Arctic Data Center. [doi:10.18739/A25M6282K](https://doi.org/10.18739/A25M6282K)
## Screenshots

Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
url: "/metacatui"
highlighter: "rouge"
version: "2.27.0"
version: "2.27.1"
22 changes: 11 additions & 11 deletions docs/docs/AccessPolicy.html
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ <h4 class="name" id="getSubjectInfo">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line312">line 312</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line311">line 311</a>
</li></ul></dd>


Expand Down Expand Up @@ -659,7 +659,7 @@ <h4 class="name" id="hasOwner">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line339">line 339</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line338">line 338</a>
</li></ul></dd>


Expand Down Expand Up @@ -822,7 +822,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line248">line 248</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line247">line 247</a>
</li></ul></dd>


Expand Down Expand Up @@ -944,7 +944,7 @@ <h4 class="name" id="isAuthorizedUpdateSysMeta">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line288">line 288</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line287">line 287</a>
</li></ul></dd>


Expand Down Expand Up @@ -1057,7 +1057,7 @@ <h4 class="name" id="isPublic">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line222">line 222</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line221">line 221</a>
</li></ul></dd>


Expand Down Expand Up @@ -1170,7 +1170,7 @@ <h4 class="name" id="makePrivate">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line155">line 155</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line154">line 154</a>
</li></ul></dd>


Expand Down Expand Up @@ -1265,7 +1265,7 @@ <h4 class="name" id="makePublic">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line182">line 182</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line181">line 181</a>
</li></ul></dd>


Expand Down Expand Up @@ -1553,7 +1553,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line328">line 328</a>
<a href="src_js_collections_AccessPolicy.js.html">src/js/collections/AccessPolicy.js</a>, <a href="src_js_collections_AccessPolicy.js.html#line327">line 327</a>
</li></ul></dd>


Expand Down Expand Up @@ -1594,7 +1594,7 @@ <h4 class="name" id="serialize">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="link" class="svg-inline--fa fa-link fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"></path></svg>

</a>
<span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span>
<span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span>
</h4>


Expand Down Expand Up @@ -1677,7 +1677,7 @@ <h5>Returns:</h5>


<div class="param-desc">
A string of the access policy XML
A XML object of the access policy or null if empty
</div>


Expand All @@ -1688,7 +1688,7 @@ <h5>Returns:</h5>
</dt>
<dd>

<span class="param-type">string</span>
<span class="param-type">object</span>


</dd>
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/AccessRule.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ <h4 class="name" id=".getSubjectInfo">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line100">line 100</a>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line124">line 124</a>
</li></ul></dd>


Expand Down Expand Up @@ -328,7 +328,7 @@ <h4 class="name" id=".isGroup">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line206">line 206</a>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line230">line 230</a>
</li></ul></dd>


Expand Down Expand Up @@ -552,7 +552,7 @@ <h4 class="name" id=".serialize">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="link" class="svg-inline--fa fa-link fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"></path></svg>

</a>
<span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span>
<span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span>
</h4>


Expand Down Expand Up @@ -606,7 +606,7 @@ <h4 class="name" id=".serialize">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line60">line 60</a>
<a href="src_js_models_AccessRule.js.html">src/js/models/AccessRule.js</a>, <a href="src_js_models_AccessRule.js.html#line89">line 89</a>
</li></ul></dd>


Expand Down Expand Up @@ -635,7 +635,7 @@ <h5>Returns:</h5>


<div class="param-desc">
The access rule XML string
The access rule XML object or null if not created
</div>


Expand All @@ -646,7 +646,7 @@ <h5>Returns:</h5>
</dt>
<dd>

<span class="param-type">string</span>
<span class="param-type">object</span>


</dd>
Expand Down
35 changes: 17 additions & 18 deletions docs/docs/src_js_collections_AccessPolicy.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,27 @@ <h1 class="page-title">Source: src/js/collections/AccessPolicy.js</h1>
},

/**
* Creates an access policy XML from the values set on the member
* AccessRule models.
* @return {string} A string of the access policy XML
*/
serialize: function(){

if( this.length == 0 )
return "";
* Creates an access policy XML from the values set on the member
* AccessRule models.
* @returns {object} A XML object of the access policy or null if empty
*/
serialize: function() {
if (this.length === 0) {
return null;
}

//Create the access policy node which will contain all the rules
var xml = "&lt;accessPolicy>\n";
// Create the access policy node which will contain all the rules
var accessPolicyElement = document.createElement('accesspolicy');

//Serialize each AccessRule member model and add to the policy DOM
this.each(function(accessRule){
xml += accessRule.serialize();
// Serialize each AccessRule member model and add to the policy DOM
this.each(function(accessRule) {
var accessRuleNode = accessRule.serialize();
if (accessRuleNode) {
accessPolicyElement.appendChild(accessRuleNode);
}
});

xml += "\n&lt;/accessPolicy>"

//Convert the access policy DOM to a string and return it
return xml;

return accessPolicyElement;
},

/**
Expand Down
126 changes: 75 additions & 51 deletions docs/docs/src_js_models_AccessRule.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,71 +74,95 @@ <h1 class="page-title">Source: src/js/models/AccessRule.js</h1>
},

/**
* Translates the access rule XML DOM into a JSON object to be set on the model.
* @param {Element} accessRuleXML An &lt;allow> DOM element that contains a single access rule
* @return {JSON} The Access Rule values to be set on this model
*/
parse: function( accessRuleXML ){
//If there is no access policy, do not attempt to parse anything
if( typeof accessRuleXML == "undefined" || !accessRuleXML)
return {};

accessRuleXML = $(accessRuleXML);

//Start an access rule object with the given subject
var parsedAccessRule = {
subject: accessRuleXML.find("subject").text()
}

_.each( accessRuleXML.find("permission"), function( permissionNode ){
parsedAccessRule[ $(permissionNode).text() ] = true;
});
* Translates the access rule XML DOM into a JSON object to be set on the model.
* @param {Element} accessRuleXML An &lt;allow> DOM element that contains a single access rule
* @return {JSON} The Access Rule values to be set on this model
*/
parse: function(accessRuleXML) {
// If there is no access policy, do not attempt to parse anything
if (typeof accessRuleXML === "undefined" || !accessRuleXML) {
return {};
}

return parsedAccessRule;
var accessRuleXMLObj = $(accessRuleXML);

},
// Start an access rule object with the given subject
var parsedAccessRule = {
subject: accessRuleXMLObj.find("subject").text()
};

/**
* Takes the values set on this model's attributes and creates an XML string
* to be inserted into a DataONEObject's system metadata access policy.
* @return {string} The access rule XML string
*/
serialize: function(){
_.each(accessRuleXMLObj.find("permission"), function(permissionNode, idx) {
let permissionText = $(permissionNode).text().trim();

var xml = "";
// Check if the permission text is not empty
if (permissionText.length) {
// Save the parsed permission
parsedAccessRule[permissionText] = true;
} else {
// This is added as a workaround for malformed permission XML
// introduced by Chromium 120.X
// See https://github.com/NCEAS/metacatui/issues/2235

//Serialize the allow rules
if( this.get("read") || this.get("write") || this.get("changePermission") ){
// Define the regular expression
let globalPermRegex = /&lt;permission>&lt;\/permission>(.*)/g;
// Define the regular expression
let permRegex = /&lt;permission>&lt;\/permission>(.*)/;

//Start the "allow" node
xml += '\t&lt;allow>\n';
let accessRoleStr = accessRuleXMLObj.html();

//Add the subject
xml += '\t\t&lt;subject>' + this.get("subject") + '&lt;/subject>\n';
let matches = accessRoleStr.match(globalPermRegex);

//Add the read permission
if( this.get("read") ){
xml += '\t\t&lt;permission>read&lt;/permission>\n';
}
// Check if matches exist and have a length
if (matches &amp;&amp; matches.length &amp;&amp; idx &lt; matches.length) {
let permMatch = matches[idx].match(permRegex);

//Add the write permission
if( this.get("write") ){
xml += '\t\t&lt;permission>write&lt;/permission>\n';
}
// Check if permMatch exists and has a length
if (permMatch &amp;&amp; permMatch.length) {
parsedAccessRule[permMatch[1]] = true;
}
}
}
});

//Add the changePermission permission
if( this.get("changePermission") ){
xml += '\t\t&lt;permission>changePermission&lt;/permission>\n';
}
return parsedAccessRule;
},

//Close the "allow" node
xml += '\t&lt;/allow>\n';
/**
* Takes the values set on this model's attributes and creates an XML string
* to be inserted into a DataONEObject's system metadata access policy.
* @returns {object} The access rule XML object or null if not created
*/
serialize: function() {
// Serialize the allow rules
if (this.get("read") || this.get("write") || this.get("changePermission")) {
// Create the &lt;allow> element
var allowElement = document.createElement('allow');

// Create the &lt;subject> element and set its text content
var subjectElement = document.createElement('subject');
subjectElement.textContent = this.get("subject");

// Append the &lt;subject> and &lt;permission> elements to &lt;allow>
allowElement.appendChild(subjectElement);

// Create the &lt;permission> elements and set their text content
var permissions = ['read', 'write', 'changePermission'];
for (var i = 0; i &lt; permissions.length; i++) {
if (this.get(permissions[i])) {
var permissionElement = document.createElement('permission');
permissionElement.textContent = permissions[i];
allowElement.appendChild(permissionElement);
}
}

}
// Return the &lt;allow> element
return allowElement;
}

return xml;
// If no access rule is created, return null
return null;
},

},

/**
* Gets and sets the subject info for the subjects in this access policy.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MetacatUI is an open source, community project. We [welcome contributions](http

Cite this software as:

> Matthew B. Jones, Chris Jones, Lauren Walker, Robyn Thiessen-Bock, Ben Leinfelder, Peter Slaughter, Bryce Mecum, Rushiraj Nenuji, Hesham Elbashandy, Val Hendrix. 2022. MetacatUI: A client-side web interface for DataONE data repositories (version 2.24.0). Arctic Data Center. [doi:10.18739/A25M6282K](https://doi.org/10.18739/A25M6282K)
> Matthew B. Jones, Chris Jones, Lauren Walker, Robyn Thiessen-Bock, Ben Leinfelder, Peter Slaughter, Bryce Mecum, Rushiraj Nenuji, Hesham Elbashandy, Val Hendrix. 2023. MetacatUI: A client-side web interface for DataONE data repositories (version 2.27.1). Arctic Data Center. [doi:10.18739/A25M6282K](https://doi.org/10.18739/A25M6282K)
## Related Projects

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metacatui",
"version": "2.27.0",
"version": "2.27.1",
"description": "MetacatUI: A client-side web interface for DataONE data repositories",
"main": "server.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

//Create the MetacatUI object
var MetacatUI = {};
MetacatUI.metacatUIVersion = "2.27.0";
MetacatUI.metacatUIVersion = "2.27.1";

//Catch errors when the config or loader file fails to load.
// These are mainly helpful for developers/operators installing MetacatUI
Expand Down
Loading

0 comments on commit fd3027d

Please sign in to comment.