Skip to content

Commit

Permalink
Improved template security
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Croker committed Feb 17, 2021
1 parent 06604fe commit f3a7a8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/templates/_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2>{{ settings.errorTitle }}</h2>

<form action="" method="post">
{% for name, value in postedValues if name != 'snaptcha' %}
<input type="hidden" name="{{ name }}" value="{{ value }}">
{{ hiddenInput(name, value) }}
{% endfor %}

{{ craft.snaptcha.field }}
Expand Down
26 changes: 13 additions & 13 deletions src/templates/_settings.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% import '_includes/forms' as forms %}

{% macro configWarning(setting) -%}
{{ "This is being overridden by the {setting} config setting."|t('app', {setting: '<code>' ~ setting ~ '</code>' })|raw }}
{{ 'This is being overridden by the `{setting}` config setting.'|t('snaptcha', {setting: setting })|markdown(inlineOnly=true) }}
{%- endmacro %}

{% from _self import configWarning %}
Expand Down Expand Up @@ -124,10 +124,10 @@
errors: settings.getErrors('minimumSubmitTime'),
}) }}

<input type="hidden" name="excludeControllerActions" value="" />
{{ hiddenInput('excludeControllerActions', '') }}
{{ forms.editableTableField({
label: "Exclude Controller Actions"|t('snaptcha'),
instructions: "The controller actions to exclude from validation. Example: `users/save-user`"|t('snaptcha'),
label: 'Exclude Controller Actions'|t('snaptcha'),
instructions: 'The controller actions to exclude from validation. Example: `users/save-user`'|t('snaptcha'),
warning: (config.excludeControllerActions is defined ? configWarning('excludeControllerActions')),
name: 'excludeControllerActions',
id: 'excludeControllerActions',
Expand All @@ -139,12 +139,12 @@
},
],
rows: settings.excludeControllerActions,
addRowLabel: "Add a controller action"|t('snaptcha'),
addRowLabel: 'Add a controller action'|t('snaptcha'),
}) }}

<input type="hidden" name="allowList" value="" />
{{ hiddenInput('allowList', '') }}
{{ forms.editableTableField({
label: "Allow List"|t('snaptcha'),
label: 'Allow List'|t('snaptcha'),
instructions: 'IP addresses to allow for all form submissions.'|t('snaptcha'),
warning: (config.allowList is defined ? configWarning('allowList')),
name: 'allowList',
Expand All @@ -155,13 +155,13 @@
heading: 'IP Address'|t('snaptcha'),
},
],
rows: settings.blacklist,
addRowLabel: "Add an IP address"|t('snaptcha'),
rows: settings.allowList,
addRowLabel: 'Add an IP address'|t('snaptcha'),
}) }}

<input type="hidden" name="denyList" value="" />
{{ hiddenInput('denyList', '') }}
{{ forms.editableTableField({
label: "Deny List"|t('snaptcha'),
label: 'Deny List'|t('snaptcha'),
instructions: 'IP addresses to deny for all form submissions.'|t('snaptcha'),
warning: (config.denyList is defined ? configWarning('denyList')),
name: 'denyList',
Expand All @@ -172,6 +172,6 @@
heading: 'IP Address'|t('snaptcha'),
},
],
rows: settings.blacklist,
addRowLabel: "Add an IP address"|t('snaptcha'),
rows: settings.denyList,
addRowLabel: 'Add an IP address'|t('snaptcha'),
}) }}

0 comments on commit f3a7a8e

Please sign in to comment.