Skip to content

Commit

Permalink
Merge branch 'release/3.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Sep 19, 2019
2 parents c93dc82 + d0738e2 commit 84fae42
Show file tree
Hide file tree
Showing 38 changed files with 925 additions and 488 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v3.0.9
## 09/19/2019

1. [](#improved)
* Removed jQuery dependency for the reCaptcha field and VanillaJS-ified it instead
* Updated to ReCaptcha library version `1.2.3`
1. [](#bugfix)
* Fixed `Badly encoded JSON data` warning when uploading files [grav#2663](https://github.com/getgrav/grav/issues/2663)

# v3.0.8
## 08/14/2019

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Form
version: 3.0.8
version: 3.0.9
testing: false
description: Enables the forms handling
icon: check-square
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 41 additions & 20 deletions templates/forms/fields/captcha/captcha.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,59 @@
{#{% do assets.addJs('https://www.google.com/recaptcha/api.js?render='~site_key) %}#}
<script src='https://www.google.com/recaptcha/api.js?render={{ site_key }}&theme={{ theme }}'></script>
<script>
jQuery('form').each(function(index, form) {
form = jQuery(form);
form.on('submit', function() {
(document.querySelectorAll('form') || []).forEach(function(form, index) {
var submit = function(event) {
event.preventDefault();
var form = jQuery(this);
grecaptcha.ready(function () {
grecaptcha.execute('{{ site_key }}', {action: '{{ action }}'}).then(function (token) {
form.prepend('<input type="hidden" name="data[token]" value="' + token + '">');
form.prepend('<input type="hidden" name="data[action]" value="{{ action }}">');
form.off('submit').submit();
grecaptcha.execute('{{ site_key }}', { action: '{{ action }}' }).then(function(token) {
var tokenElement = document.createElement('input');
tokenElement.setAttribute('type', 'hidden');
tokenElement.setAttribute('name', 'data[token]');
tokenElement.setAttribute('value', token);
var actionElement = document.createElement('input');
actionElement.setAttribute('type', 'hidden');
actionElement.setAttribute('name', 'data[action]');
actionElement.setAttribute('value', '{{ action }}');
form.insertBefore(tokenElement, form.firstChild);
form.insertBefore(actionElement, form.firstChild);
form.removeEventListener('submit', submit);
form.submit();
});
});
});
};
form.addEventListener('submit', submit);
});
</script>
{% elseif config.plugins.form.recaptcha.version == '2-invisible' %}
<script>
function captchaOnloadCallback_{{ formName }}() {
var form = jQuery('form#{{ form.id }}');
form.find('[type="submit"]').on('click', function(event) {
event.preventDefault();
var form = document.querySelector('form#{{ form.id }}');
var submits = form.querySelectorAll('[type="submit"]') || [];
submits.forEach(function(submit) {
submit.addEventListener('click', function(event) {
event.preventDefault();
var captchaElement = form.querySelector('#g-recaptcha-{{ formName }}');
form.append('<div id="g-recaptcha-{{ formName }}"></div>');
var widgetReference = grecaptcha.render('g-recaptcha-{{ formName }}', {
sitekey: '{{ site_key }}', size: 'invisible',
callback: function(/* token */) {
form.submit();
if (captchaElement) {
captchaElement.remove();
}
});
grecaptcha.execute(widgetReference);
captchaElement = document.createElement('div');
captchaElement.setAttribute('id', 'g-recaptcha-{{ formName }}');
form.appendChild(captchaElement);
var widgetReference = grecaptcha.render('g-recaptcha-{{ formName }}', {
sitekey: '{{ site_key }}', size: 'invisible',
callback: function(/* token */) {
form.submit();
}
});
grecaptcha.execute(widgetReference);
});
});
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion templates/forms/fields/file/file.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
{% for path, file in value %}
{{ macro.preview(path, file, _context) }}
{% endfor %}
{% include 'forms/fields/hidden/hidden.html.twig' with {field: {name: '_json.' ~ field.name}, value: value|json_encode} %}
{% include 'forms/fields/hidden/hidden.html.twig' with {field: {name: '_json.' ~ field.name}, value: (value ?? [])|json_encode } %}
</div>

{% if grav.browser.browser == 'msie' and grav.browser.version < 12 %}
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function isClassMapAuthoritative()
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}

/**
Expand Down Expand Up @@ -377,7 +377,7 @@ private function findFileWithExtension($class, $ext)
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
Expand Down
16 changes: 8 additions & 8 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[
{
"name": "google/recaptcha",
"version": "1.2.1",
"version_normalized": "1.2.1.0",
"version": "1.2.3",
"version_normalized": "1.2.3.0",
"source": {
"type": "git",
"url": "https://github.com/google/recaptcha.git",
"reference": "e7add3be59211482ecdb942288f52da64a35f61a"
"reference": "98c4a6573b27e8b0990ea8789c74ea378795134c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/google/recaptcha/zipball/e7add3be59211482ecdb942288f52da64a35f61a",
"reference": "e7add3be59211482ecdb942288f52da64a35f61a",
"url": "https://api.github.com/repos/google/recaptcha/zipball/98c4a6573b27e8b0990ea8789c74ea378795134c",
"reference": "98c4a6573b27e8b0990ea8789c74ea378795134c",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2.20|^2.12",
"friendsofphp/php-cs-fixer": "^2.2.20|^2.15",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7"
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11"
},
"time": "2018-08-05T09:31:53+00:00",
"time": "2019-08-16T15:48:25+00:00",
"type": "library",
"extra": {
"branch-alias": {
Expand Down
1 change: 1 addition & 0 deletions vendor/google/recaptcha/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.php_cs.cache
/.phpunit.result.cache
/build
/composer.lock
/examples/config.php
Expand Down
2 changes: 2 additions & 0 deletions vendor/google/recaptcha/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'

before_script:
- composer install
Expand Down
46 changes: 23 additions & 23 deletions vendor/google/recaptcha/LICENSE
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
Copyright 2014, Google Inc.
BSD 3-Clause License

Copyright (c) 2019, Google Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 changes: 3 additions & 2 deletions vendor/google/recaptcha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
[![Latest Stable Version](https://poser.pugx.org/google/recaptcha/v/stable.svg)](https://packagist.org/packages/google/recaptcha)
[![Total Downloads](https://poser.pugx.org/google/recaptcha/downloads.svg)](https://packagist.org/packages/google/recaptcha)

reCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse.
reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse.
This is a PHP library that wraps up the server-side verification step required
to process responses from the reCAPTCHA service. This client supports both v2
and v3.

- reCAPTCHA: https://www.google.com/recaptcha
- This repo: https://github.com/google/recaptcha
- Version: 1.2.1
- Hosted demo: https://recaptcha-demo.appspot.com/
- Version: 1.2.3
- License: BSD, see [LICENSE](LICENSE)

## Installation
Expand Down
4 changes: 2 additions & 2 deletions vendor/google/recaptcha/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7",
"friendsofphp/php-cs-fixer": "^2.2.20|^2.12",
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11",
"friendsofphp/php-cs-fixer": "^2.2.20|^2.15",
"php-coveralls/php-coveralls": "^2.1"
},
"autoload": {
Expand Down
43 changes: 26 additions & 17 deletions vendor/google/recaptcha/examples/appengine-https.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2015, Google Inc.
* @link https://www.google.com/recaptcha
* BSD 3-Clause License
* @copyright (c) 2019, Google Inc.
* @link https://www.google.com/recaptcha
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// Redirect to HTTPS by default (for AppEngine)
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'http') {
Expand Down
31 changes: 31 additions & 0 deletions vendor/google/recaptcha/examples/config.php.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
<?php
/**
* BSD 3-Clause License
* @copyright (c) 2019, Google Inc.
* @link https://www.google.com/recaptcha
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

return [
'v2-standard' => [
'site' => '',
Expand Down
Loading

0 comments on commit 84fae42

Please sign in to comment.