Skip to content

Commit c926bf7

Browse files
claravoxlwesterhof
authored andcommitted
YDA-6465: prevent create very long (sub)category names, desc
1 parent dcb08a4 commit c926bf7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

group_manager/static/group_manager/js/group_manager.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ $(function () {
18251825
}
18261826

18271827
if (!newProperties.name.startsWith('datamanager-') && !newProperties.name.match(/^(intake|research|deposit)-([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/)) {
1828-
window.alert('Group names may only contain lowercase letters (a-z) and hyphens (-).')
1828+
window.alert('Group names may only contain numbers, lowercase letters (a-z), and hyphens (-).')
18291829
resetSubmitButton()
18301830
return
18311831
}
@@ -1835,6 +1835,10 @@ $(function () {
18351835
window.alert('Please select a category.')
18361836
resetSubmitButton()
18371837
return
1838+
} else if (newProperties.category.length > 2700) {
1839+
window.alert('The category name may be a max of 2700 characters long.')
1840+
resetSubmitButton()
1841+
return
18381842
} else if (!newProperties.category.match(/^([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/)) {
18391843
window.alert('The category name may only contain lowercase letters (a-z) and hyphens (-).')
18401844
resetSubmitButton()
@@ -1846,6 +1850,10 @@ $(function () {
18461850
window.alert('Please select a subcategory.')
18471851
resetSubmitButton()
18481852
return
1853+
} else if (newProperties.subcategory.length > 2700) {
1854+
window.alert('The subcategory name may be a max of 2700 characters long.')
1855+
resetSubmitButton()
1856+
return
18491857
} else if (!newProperties.subcategory.match(/^[a-zA-Z0-9,.()_ -]*$/)) {
18501858
window.alert('The subcategory name may only contain letters a-z, numbers, spaces, comma\'s, periods, parentheses, underscores (_) and hyphens (-).')
18511859
resetSubmitButton()
@@ -1881,6 +1889,10 @@ $(function () {
18811889
window.alert('The group description may only contain letters a-z, numbers, spaces, comma\'s, periods, parentheses, underscores (_) and hyphens (-).')
18821890
resetSubmitButton()
18831891
return
1892+
} else if (newProperties.description.length > 2700) {
1893+
window.alert('The group description may be a max of 2700 characters long.')
1894+
resetSubmitButton()
1895+
return
18841896
}
18851897

18861898
const postData = {
@@ -2017,16 +2029,16 @@ $(function () {
20172029
},
20182030

20192031
/**
2020-
* \brief User add form submission handler.
2021-
*
2022-
* Adds a user to the selected group.
2023-
*
2024-
* `this` is assumed to be the groupManager object, not the form element
2025-
* that was submitted.
2026-
*
2027-
* \param el the form element
2028-
* \param e a submit event
2029-
*/
2032+
* \brief User add form submission handler.
2033+
*
2034+
* Adds a user to the selected group.
2035+
*
2036+
* `this` is assumed to be the groupManager object, not the form element
2037+
* that was submitted.
2038+
*
2039+
* \param el the form element
2040+
* \param e a submit event
2041+
*/
20302042
onSubmitUserCreate: async function (el, e) {
20312043
e.preventDefault()
20322044

0 commit comments

Comments
 (0)