In this next small update, I made a few changes to protect against XXS attacks
in the moderation panel.
This commit is contained in:
parent
c906887025
commit
a02831687a
@ -33,60 +33,57 @@ def take_punitive_actions(request, form, report, user):
|
|||||||
for privilege_name in form.take_away_privileges.data:
|
for privilege_name in form.take_away_privileges.data:
|
||||||
take_away_privileges(user.username, privilege_name)
|
take_away_privileges(user.username, privilege_name)
|
||||||
form.resolution_content.data += \
|
form.resolution_content.data += \
|
||||||
u"<br>%s took away %s\'s %s privileges." % (
|
u"\n{mod} took away {user}\'{privilege} privileges.".format(
|
||||||
request.user.username,
|
mod=request.user.username,
|
||||||
user.username,
|
user=user.username,
|
||||||
privilege_name)
|
privilege=privilege_name)
|
||||||
|
|
||||||
# If the moderator elects to ban the user, a new instance of user_ban
|
# If the moderator elects to ban the user, a new instance of user_ban
|
||||||
# will be created.
|
# will be created.
|
||||||
if u'userban' in form.action_to_resolve.data:
|
if u'userban' in form.action_to_resolve.data:
|
||||||
reason = form.resolution_content.data + \
|
|
||||||
"<br>"+request.user.username
|
|
||||||
user_ban = ban_user(form.targeted_user.data,
|
user_ban = ban_user(form.targeted_user.data,
|
||||||
expiration_date=form.user_banned_until.data,
|
expiration_date=form.user_banned_until.data,
|
||||||
reason=form.why_user_was_banned.data)
|
reason=form.why_user_was_banned.data)
|
||||||
Session.add(user_ban)
|
Session.add(user_ban)
|
||||||
|
form.resolution_content.data += \
|
||||||
if form.user_banned_until.data is not None:
|
u"\n{mod} banned user {user} until {expiration_date}.".format(
|
||||||
form.resolution_content.data += \
|
mod=request.user.username,
|
||||||
u"<br>%s banned user %s until %s." % (
|
user=user.username,
|
||||||
request.user.username,
|
expiration_date = (
|
||||||
user.username,
|
"until {date}".format(date=form.user_banned_until.data)
|
||||||
form.user_banned_until.data)
|
if form.user_banned_until.data
|
||||||
else:
|
else "indefinitely"
|
||||||
form.resolution_content.data += \
|
)
|
||||||
u"<br>%s banned user %s indefinitely." % (
|
)
|
||||||
request.user.username,
|
|
||||||
user.username)
|
|
||||||
|
|
||||||
# If the moderator elects to send a warning message. An email will be
|
# If the moderator elects to send a warning message. An email will be
|
||||||
# sent to the email address given at sign up
|
# sent to the email address given at sign up
|
||||||
if u'sendmessage' in form.action_to_resolve.data:
|
if u'sendmessage' in form.action_to_resolve.data:
|
||||||
message_body = form.message_to_user.data
|
message_body = form.message_to_user.data
|
||||||
form.resolution_content.data += \
|
form.resolution_content.data += \
|
||||||
u"<br>%s sent a warning email to the offender." % (
|
u"\n{mod} sent a warning email to the {user}.".format(
|
||||||
request.user.username)
|
mod=request.user.username,
|
||||||
|
user=user.username)
|
||||||
|
|
||||||
if u'delete' in form.action_to_resolve.data and \
|
if u'delete' in form.action_to_resolve.data and \
|
||||||
report.is_comment_report():
|
report.is_comment_report():
|
||||||
deleted_comment = report.comment
|
deleted_comment = report.comment
|
||||||
Session.delete(deleted_comment)
|
Session.delete(deleted_comment)
|
||||||
form.resolution_content.data += \
|
form.resolution_content.data += \
|
||||||
u"<br>%s deleted the comment." % (
|
u"\n{mod} deleted the comment.".format(
|
||||||
request.user.username)
|
mod=request.user.username)
|
||||||
elif u'delete' in form.action_to_resolve.data and \
|
elif u'delete' in form.action_to_resolve.data and \
|
||||||
report.is_media_entry_report():
|
report.is_media_entry_report():
|
||||||
deleted_media = report.media_entry
|
deleted_media = report.media_entry
|
||||||
Session.delete(deleted_media)
|
Session.delete(deleted_media)
|
||||||
form.resolution_content.data += \
|
form.resolution_content.data += \
|
||||||
u"<br>%s deleted the media entry." % (
|
u"\n{mod} deleted the media entry.".format(
|
||||||
request.user.username)
|
mod=request.user.username)
|
||||||
report.archive(
|
report.archive(
|
||||||
resolver_id=request.user.id,
|
resolver_id=request.user.id,
|
||||||
resolved=datetime.now(),
|
resolved=datetime.now(),
|
||||||
result=form.resolution_content.data)
|
result=form.resolution_content.data)
|
||||||
|
|
||||||
Session.add(report)
|
Session.add(report)
|
||||||
Session.commit()
|
Session.commit()
|
||||||
if message_body:
|
if message_body:
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
title="Return to Reports Panel">
|
title="Return to Reports Panel">
|
||||||
{% trans %}Return to Reports Panel{% endtrans %}</a>
|
{% trans %}Return to Reports Panel{% endtrans %}</a>
|
||||||
<h2>{% trans %}Report{% endtrans %} #{{ report.id }}</h2>
|
<h2>{% trans %}Report{% endtrans %} #{{ report.id }}</h2>
|
||||||
{% if report.is_comment_report() or
|
{% if report.comment %}
|
||||||
(report.is_archived_report() and report.comment) %}
|
|
||||||
|
|
||||||
{% trans %}Reported comment{% endtrans %}:
|
{% trans %}Reported comment{% endtrans %}:
|
||||||
{% set comment = report.comment %}
|
{% set comment = report.comment %}
|
||||||
@ -63,8 +62,7 @@
|
|||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% elif report.is_media_entry_report() or
|
{% elif report.media_entry %}
|
||||||
(report.is_archived_report() and report.media_entry) %}
|
|
||||||
|
|
||||||
{% set media_entry = report.media_entry %}
|
{% set media_entry = report.media_entry %}
|
||||||
<div class="media_thumbnail">
|
<div class="media_thumbnail">
|
||||||
@ -137,7 +135,7 @@
|
|||||||
init_report_resolution_form();
|
init_report_resolution_form();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% elif not (report.reported_user.has_privilege('admin')) %}
|
{% elif report.is_archived_report() %}
|
||||||
<h2><img src="{{ request.staticdirect('/images/icon_clipboard.png') }}"
|
<h2><img src="{{ request.staticdirect('/images/icon_clipboard.png') }}"
|
||||||
alt="Under a GNU LGPL v.3 or Creative Commons BY-SA 3.0 license.
|
alt="Under a GNU LGPL v.3 or Creative Commons BY-SA 3.0 license.
|
||||||
Distributed by the GNOME project http://www.gnome.org" />
|
Distributed by the GNOME project http://www.gnome.org" />
|
||||||
@ -145,9 +143,9 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<b>{% trans %}RESOLVED{% endtrans %}</b>
|
<b>{% trans %}RESOLVED{% endtrans %}</b>
|
||||||
{{ report.resolved.strftime("%I:%M%p %Y-%m-%d") }}
|
{{ report.resolved.strftime("%I:%M%p %Y-%m-%d") }}
|
||||||
{% autoescape False %}
|
<pre>
|
||||||
<p>{{ report.result }}</p>
|
<p>{{ report.result }}</p>
|
||||||
{% endautoescape %}
|
</pre>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type=button disabled=disabled value="Resolve This Report"/>
|
<input type=button disabled=disabled value="Resolve This Report"/>
|
||||||
<p>You cannot take action against an administrator</p>
|
<p>You cannot take action against an administrator</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user