Limit reason field length

This commit is contained in:
rubenwardy 2024-06-02 12:33:40 +01:00
parent 6b04324ee5
commit 54c50a815d
2 changed files with 6 additions and 4 deletions

@ -464,12 +464,14 @@ def remove(package):
hard_deps = Package.query.filter( hard_deps = Package.query.filter(
Package.state == PackageState.APPROVED, Package.state == PackageState.APPROVED,
Package.dependencies.any( Package.dependencies.any(
and_(Dependency.meta_package_id.in_([x.id for x in broken_meta]), Dependency.optional == False))) and_(Dependency.meta_package_id.in_([x.id for x in broken_meta]), Dependency.optional == False))).all()
return render_template("packages/remove.html", package=package, hard_deps=hard_deps, return render_template("packages/remove.html", package=package, hard_deps=hard_deps,
tabs=get_package_tabs(current_user, package), current_tab="remove") tabs=get_package_tabs(current_user, package), current_tab="remove")
reason = request.form.get("reason") or "?" reason = request.form.get("reason") or "?"
if len(reason) > 500:
abort(400)
if "delete" in request.form: if "delete" in request.form:
if not package.check_perm(current_user, Permission.DELETE_PACKAGE): if not package.check_perm(current_user, Permission.DELETE_PACKAGE):

@ -10,8 +10,8 @@ Remove {{ package.title }}
<p> <p>
{{ _("In order to avoid data loss, you cannot permanently delete packages. {{ _("In order to avoid data loss, you cannot permanently delete packages.
You can remove them from ContentDB, which will cause them to not be You can remove them from ContentDB, which will cause them to not be
visible to any users and they may be permanently deleted in the future. visible to any users. Removed packages may be permanently deleted at a
The Admin can restore removed packages, if needed.") }} later point. ContentDB staff can restore removed packages, if needed.") }}
</p> </p>
{% if package.approved %} {% if package.approved %}
@ -47,7 +47,7 @@ Remove {{ package.title }}
<span class="ms-3 text-muted"> <span class="ms-3 text-muted">
{{ _("Required") }} {{ _("Required") }}
</span> </span>
<input id="reason" class="form-control" type="text" name="reason" required minlength="5"> <input id="reason" class="form-control" type="text" name="reason" required minlength="5" maxlength="500">
<small class="form-text text-muted"> <small class="form-text text-muted">
{{ _("Reason for unapproval / deletion, this is shown in the audit log") }} {{ _("Reason for unapproval / deletion, this is shown in the audit log") }}
</small> </small>