Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add 10 MB max length checks to form field editor #2584

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ function EditFieldsModalController(
return Object.keys(myDict).length !== field.fieldOptions.length
}

vm.showFieldDataTooLongError = function (field) {
return JSON.stringify(field).length > 10 * MB
}

vm.showEmptyOptionsError = function (field) {
// Empty options should only appear on fields that have options to choose from
// A blank option is considered to be a non-empty option
Expand Down Expand Up @@ -384,6 +388,9 @@ function EditFieldsModalController(
}

vm.disableSave = function () {
if (vm.showFieldDataTooLongError(vm.field)) {
return true
}
if (
vm.field.fieldType === 'attachment' ||
vm.field.fieldType === 'dropdown' ||
Expand Down
12 changes: 12 additions & 0 deletions src/public/modules/forms/admin/views/edit-fields.client.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,18 @@ <h2 class="modal-title">
</div>
</div>

<div class="row" ng-if="vm.showFieldDataTooLongError(vm.field)">
<div class="col-md-12">
<div class="alert-custom alert-error">
<i class="bx bx-exclamation bx-md icon-spacing"></i>
<span class="alert-msg"
>Your field size has exceeded 10 MB. Please reduce the size of
the field.</span
>
</div>
</div>
</div>

<!-- Rating -->
<div class="row" ng-if="vm.field.fieldType === 'rating'">
<div id="rating-options">
Expand Down