Remove deprecated Recaptcha-related classes (#4289)
authorMatthias Schmidt <gravatronics@live.com>
Tue, 15 Jun 2021 05:58:12 +0000 (07:58 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Jun 2021 05:58:12 +0000 (07:58 +0200)
See #4281

com.woltlab.wcf/fileDelete.xml
wcfsetup/install/files/lib/form/RecaptchaForm.class.php [deleted file]
wcfsetup/install/files/lib/system/recaptcha/RecaptchaHandlerV2.class.php [deleted file]

index 0c7e67556e4523812243486a05ceee9804d727ec..62c5ad925083d1bd959911876cdeeb698624ccda 100644 (file)
                <file>lib/form/AbstractSecureForm.class.php</file>
                <file>lib/form/MailForm.class.php</file>
                <file>lib/form/MultifactorAuthenticationAbortForm.class.php</file>
+               <file>lib/form/RecaptchaForm.class.php</file>
                <file>lib/page/CookiePolicyPage.class.php</file>
                <file>lib/page/DashboardPage.class.php</file>
                <file>lib/page/LessStylesheetsPage.class.php</file>
                <file>lib/system/page/location/IPageLocation.class.php</file>
                <file>lib/system/payment/method/SofortUeberweisungPaymentMethod.class.php</file>
                <file>lib/system/recaptcha/RecaptchaHandler.class.php</file>
+               <file>lib/system/recaptcha/RecaptchaHandlerV2.class.php</file>
                <file>lib/system/request/CmsLinkHandler.class.php</file>
                <file>lib/system/request/FlexibleRoute.class.php</file>
                <file>lib/system/request/IRoute.class.php</file>
diff --git a/wcfsetup/install/files/lib/form/RecaptchaForm.class.php b/wcfsetup/install/files/lib/form/RecaptchaForm.class.php
deleted file mode 100644 (file)
index 1c8c3a7..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-namespace wcf\form;
-
-use wcf\system\recaptcha\RecaptchaHandlerV2;
-use wcf\system\WCF;
-
-/**
- * RecaptchaForm is an abstract form implementation for the use of reCAPTCHA.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\Form
- * @deprecated  2.1
- */
-abstract class RecaptchaForm extends AbstractForm
-{
-    /**
-     * challenge
-     * @var string
-     */
-    public $challenge = '';
-
-    /**
-     * response
-     * @var string
-     */
-    public $response = '';
-
-    /**
-     * enable recaptcha
-     * @var bool
-     */
-    public $useCaptcha = true;
-
-    /**
-     * @inheritDoc
-     */
-    public function readParameters()
-    {
-        parent::readParameters();
-
-        if (WCF::getUser()->userID || WCF::getSession()->getVar('recaptchaDone')) {
-            $this->useCaptcha = false;
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function readFormParameters()
-    {
-        parent::readFormParameters();
-
-        if (isset($_POST['g-recaptcha-response'])) {
-            $this->response = $_POST['g-recaptcha-response'];
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function validate()
-    {
-        parent::validate();
-
-        $this->validateCaptcha();
-    }
-
-    /**
-     * Validates the captcha.
-     */
-    protected function validateCaptcha()
-    {
-        if ($this->useCaptcha) {
-            RecaptchaHandlerV2::getInstance()->validate($this->response);
-
-            $this->useCaptcha = false;
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function save()
-    {
-        parent::save();
-
-        WCF::getSession()->unregister('recaptchaDone');
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function assignVariables()
-    {
-        parent::assignVariables();
-
-        WCF::getTPL()->assign([
-            'recaptchaLegacyMode' => true,
-        ]);
-
-        WCF::getTPL()->assign([
-            'useCaptcha' => $this->useCaptcha,
-        ]);
-    }
-}
diff --git a/wcfsetup/install/files/lib/system/recaptcha/RecaptchaHandlerV2.class.php b/wcfsetup/install/files/lib/system/recaptcha/RecaptchaHandlerV2.class.php
deleted file mode 100644 (file)
index dd3b430..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-namespace wcf\system\recaptcha;
-
-use wcf\system\exception\UserInputException;
-use wcf\system\SingletonFactory;
-use wcf\system\WCF;
-use wcf\util\HTTPRequest;
-use wcf\util\JSON;
-use wcf\util\UserUtil;
-
-/**
- * Handles reCAPTCHA V2 support.
- *
- * @author  Tim Duesterhus
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Recaptcha
- * @deprecated  5.4 - This was an implementation detail of wcf\system\captcha\RecaptchaHandler.
- */
-class RecaptchaHandlerV2 extends SingletonFactory
-{
-    /**
-     * Validates response.
-     *
-     * @param string $response
-     * @param string $type
-     * @throws  UserInputException
-     */
-    public function validate($response, $type = 'v2')
-    {
-        // fail if response is empty to avoid sending api requests
-        if (empty($response)) {
-            throw new UserInputException('recaptchaString', 'false');
-        }
-
-        if ($type === 'v2') {
-            $key = RECAPTCHA_PRIVATEKEY;
-        } elseif ($type === 'invisible') {
-            $key = RECAPTCHA_PRIVATEKEY_INVISIBLE;
-        } else {
-            // The bot modified the `recaptcha-type` form field.
-            throw new UserInputException('recaptchaString', 'false');
-        }
-
-        $request = new HTTPRequest(
-            \sprintf(
-                'https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s&remoteip=%s',
-                \rawurlencode($key),
-                \rawurlencode($response),
-                \rawurlencode(UserUtil::getIpAddress())
-            ),
-            ['timeout' => 10]
-        );
-
-        try {
-            $request->execute();
-            $reply = $request->getReply();
-            $data = JSON::decode($reply['body']);
-
-            if ($data['success']) {
-                // yeah
-            } else {
-                throw new UserInputException('recaptchaString', 'false');
-            }
-        } catch (\Exception $e) {
-            if ($e instanceof UserInputException) {
-                throw $e;
-            }
-
-            // log error, but accept captcha
-            \wcf\functions\exception\logThrowable($e);
-        }
-
-        WCF::getSession()->register('recaptchaDone', true);
-    }
-}