Skip to content

Commit

Permalink
Merge pull request #12 from plone/Remove-unused-REMOTE_ADDR-code
Browse files Browse the repository at this point in the history
Add german translation. Remove unused remote address code
  • Loading branch information
fredvd committed Mar 28, 2024
2 parents 2be2141 + cdccda1 commit caf8a8b
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
plone-version:
Expand Down
2 changes: 1 addition & 1 deletion docs/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plone.formwidget.recaptcha is copyright Plone Foundation
plone.formwidget.hcaptcha is copyright Plone Foundation

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
1 change: 1 addition & 0 deletions news/11.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
German translation for public validator error message. [ksuess]
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"Framework :: Plone :: 5.2",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: YEAR-MO-DA HO:MI +ZONE\n"
"PO-Revision-Date: 2024-03-28 07:53+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language-Code: nl\n"
"Language-Name: Dutch\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: DOMAIN\n"
"Language: eu\n"
"X-Generator: Poedit 2.3\n"

#: ../profiles/default/controlpanel.xml
msgid "HCaptcha"
msgstr ""

#: ../restapi/controlpanel.py:16
msgid "HCaptcha Control Panel"
msgstr ""

#: ../controlpanel.py:10
msgid "HCaptcha settings"
msgstr ""

#: ../controlpanel.py:11
msgid "In order to use HCaptcha on your Plone site, go to https://www.hcaptcha.com/ to create an account and to receive your private/secret and public/site key. Then configure them at https://host/path/to/site/@@hcaptcha-settings. If you don't want to rely on an external service for captcha, you might want to consider using plone.formwidget.captcha instead."
msgstr ""

#: ../interfaces.py:57
msgid "Private Key / Secret Key"
msgstr ""

#: ../interfaces.py:50
msgid "Public Key / Site Key"
msgstr ""

#: ../interfaces.py:80
msgid "Size"
msgstr ""

#: ../interfaces.py:65
msgid "The color theme of the widget."
msgstr ""

#: ../interfaces.py:81
msgid "The size of the widget."
msgstr ""

#: ../interfaces.py:73
msgid "The type of CAPTCHA to serve."
msgstr ""

#: ../interfaces.py:64
msgid "Theme"
msgstr ""

#: ../interfaces.py:72
msgid "Type"
msgstr ""

#: ../validator.py:10
msgid "We are not yet sure whether you are human. Please try again."
msgstr "Wir sind nicht sicher ob Sie ein Mensch sind. Bitte versuchen Sie es nochmals."

#: ../interfaces.py:17
msgid "audio"
msgstr ""

#: ../interfaces.py:23
msgid "compact"
msgstr ""

#: ../interfaces.py:11
msgid "dark"
msgstr ""

#: ../interfaces.py:16
msgid "image"
msgstr ""

#: ../interfaces.py:10
msgid "light"
msgstr ""

#: ../interfaces.py:22
msgid "normal"
msgstr ""
4 changes: 1 addition & 3 deletions src/plone/formwidget/hcaptcha/nohcaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ def displayhtml(
}


def submit(hcaptcha_response_field, secret_key, remoteip, verify_server=VERIFY_SERVER):
def submit(hcaptcha_response_field, secret_key, verify_server=VERIFY_SERVER):
"""
Submits a HCAPTCHA request for verification. Returns HcaptchaResponse
for the request
hcaptcha_response_field -- The value from the form
secret_key -- your HCAPTCHA secret key
remoteip -- the user's ip address
"""

if not (hcaptcha_response_field and len(hcaptcha_response_field)):
Expand All @@ -85,7 +84,6 @@ def encode_if_necessary(s):

if six.PY2:
secret_key = encode_if_necessary(secret_key)
remoteip = encode_if_necessary(remoteip)
hcaptcha_response_field = encode_if_necessary(hcaptcha_response_field)

params = parse.urlencode(
Expand Down
6 changes: 2 additions & 4 deletions src/plone/formwidget/hcaptcha/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ def verify(self, input=None):
"path/to/site/@@hcaptcha-settings to configure."
)
response_field = self.request.get("h-captcha-response")
remote_addr = self.request.get("HTTP_X_FORWARDED_FOR", "").split(",")[0]
if not remote_addr:
remote_addr = self.request.get("REMOTE_ADDR")
res = submit(response_field, self.settings.private_key, remote_addr)

res = submit(response_field, self.settings.private_key)
if res.error_code:
info.error = res.error_code

Expand Down

0 comments on commit caf8a8b

Please sign in to comment.