Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
276bf142
Commit
276bf142
authored
Oct 07, 2022
by
Kazuhiko Shiozaki
Committed by
Arnaud Fontaine
Mar 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: md5() argument should by byte.
parent
aad0729a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
11 deletions
+12
-11
product/ERP5Form/CaptchaField.py
product/ERP5Form/CaptchaField.py
+4
-3
product/ERP5Form/CaptchasDotNet.py
product/ERP5Form/CaptchasDotNet.py
+2
-1
product/ERP5Form/Selection.py
product/ERP5Form/Selection.py
+3
-2
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+2
-4
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+1
-1
No files found.
product/ERP5Form/CaptchaField.py
View file @
276bf142
...
@@ -35,6 +35,7 @@ from Products.Formulator.Errors import ValidationError
...
@@ -35,6 +35,7 @@ from Products.Formulator.Errors import ValidationError
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
DTMLFile
from
Products.ERP5Type.Globals
import
DTMLFile
from
Products.ERP5Type.Utils
import
str2bytes
from
Products.Formulator.TALESField
import
TALESField
from
Products.Formulator.TALESField
import
TALESField
from
.
import
CaptchasDotNet
from
.
import
CaptchasDotNet
import
string
import
string
...
@@ -75,7 +76,7 @@ class CaptchasDotNetProvider(object):
...
@@ -75,7 +76,7 @@ class CaptchasDotNetProvider(object):
def
getHTML
(
self
,
field
,
captcha_key
):
def
getHTML
(
self
,
field
,
captcha_key
):
image_generator
=
self
.
getImageGenerator
(
field
)
image_generator
=
self
.
getImageGenerator
(
field
)
return
image_generator
.
image
(
captcha_key
,
"__captcha_"
+
md5
(
captcha_key
).
hexdigest
())
return
image_generator
.
image
(
captcha_key
,
"__captcha_"
+
md5
(
str2bytes
(
captcha_key
)
).
hexdigest
())
# dynamic fields
# dynamic fields
_dynamic_property_list
=
[
dict
(
id
=
'captcha_dot_net_client'
,
_dynamic_property_list
=
[
dict
(
id
=
'captcha_dot_net_client'
,
...
@@ -197,14 +198,14 @@ class CaptchaWidget(Widget.TextWidget):
...
@@ -197,14 +198,14 @@ class CaptchaWidget(Widget.TextWidget):
provider
=
CaptchaProviderFactory
.
getProvider
(
captcha_type
)
provider
=
CaptchaProviderFactory
.
getProvider
(
captcha_type
)
(
captcha_key
,
captcha_answer
)
=
provider
.
generate
(
field
)
(
captcha_key
,
captcha_answer
)
=
provider
.
generate
(
field
)
portal_sessions
=
field
.
getPortalObject
().
portal_sessions
portal_sessions
=
field
.
getPortalObject
().
portal_sessions
while
not
self
.
add_captcha
(
portal_sessions
,
md5
(
captcha_key
).
hexdigest
(),
captcha_answer
):
while
not
self
.
add_captcha
(
portal_sessions
,
md5
(
str2bytes
(
captcha_key
)
).
hexdigest
(),
captcha_answer
):
(
captcha_key
,
captcha_answer
)
=
provider
.
generate
(
field
)
(
captcha_key
,
captcha_answer
)
=
provider
.
generate
(
field
)
captcha_field
=
provider
.
getHTML
(
field
,
captcha_key
)
captcha_field
=
provider
.
getHTML
(
field
,
captcha_key
)
key_field
=
Widget
.
render_element
(
"input"
,
key_field
=
Widget
.
render_element
(
"input"
,
type
=
"hidden"
,
type
=
"hidden"
,
name
=
"__captcha_"
+
key
+
"__"
,
name
=
"__captcha_"
+
key
+
"__"
,
value
=
md5
(
captcha_key
).
hexdigest
())
value
=
md5
(
str2bytes
(
captcha_key
)
).
hexdigest
())
splitter
=
"<br />"
splitter
=
"<br />"
answer
=
Widget
.
render_element
(
"input"
,
answer
=
Widget
.
render_element
(
"input"
,
type
=
"text"
,
type
=
"text"
,
...
...
product/ERP5Form/CaptchasDotNet.py
View file @
276bf142
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
from
hashlib
import
md5
from
hashlib
import
md5
import
random
import
random
from
Products.ERP5Type.Utils
import
str2bytes
class
CaptchasDotNet
:
class
CaptchasDotNet
:
def
__init__
(
self
,
client
,
secret
,
def
__init__
(
self
,
client
,
secret
,
...
@@ -130,7 +131,7 @@ class CaptchasDotNet:
...
@@ -130,7 +131,7 @@ class CaptchasDotNet:
encryption_base
=
self
.
__secret
+
random
encryption_base
=
self
.
__secret
+
random
if
(
password_alphabet
!=
"abcdefghijklmnopqrstuvwxyz"
)
or
(
password_length
!=
6
):
if
(
password_alphabet
!=
"abcdefghijklmnopqrstuvwxyz"
)
or
(
password_length
!=
6
):
encryption_base
+=
":"
+
password_alphabet
+
":"
+
str
(
password_length
)
encryption_base
+=
":"
+
password_alphabet
+
":"
+
str
(
password_length
)
digest
=
md5
(
encryption_base
).
digest
()
digest
=
md5
(
str2bytes
(
encryption_base
)
).
digest
()
# Compute password
# Compute password
correct_password
=
''
correct_password
=
''
...
...
product/ERP5Form/Selection.py
View file @
276bf142
...
@@ -33,6 +33,7 @@ from Acquisition import aq_base
...
@@ -33,6 +33,7 @@ from Acquisition import aq_base
from
OFS.Traversable
import
Traversable
from
OFS.Traversable
import
Traversable
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
as
ERP5Permissions
from
Products.ERP5Type
import
Permissions
as
ERP5Permissions
from
Products.ERP5Type.Utils
import
str2bytes
from
Products.PythonScripts.Utility
import
allow_class
from
Products.PythonScripts.Utility
import
allow_class
from
hashlib
import
md5
from
hashlib
import
md5
...
@@ -375,8 +376,8 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
...
@@ -375,8 +376,8 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
security
.
declarePublic
(
'getAnonymousSelectionKey'
)
security
.
declarePublic
(
'getAnonymousSelectionKey'
)
def
getAnonymousSelectionKey
(
self
):
def
getAnonymousSelectionKey
(
self
):
return
md5
(
repr
({
k
:
v
for
k
,
v
in
six
.
iteritems
(
self
.
__dict__
)
return
md5
(
str2bytes
(
repr
({
k
:
v
for
k
,
v
in
six
.
iteritems
(
self
.
__dict__
)
if
k
!=
'index'
}
)).
hexdigest
()
if
k
!=
'index'
})
)).
hexdigest
()
InitializeClass
(
Selection
)
InitializeClass
(
Selection
)
allow_class
(
Selection
)
allow_class
(
Selection
)
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
276bf142
...
@@ -39,6 +39,7 @@ from ZTUtils import make_query
...
@@ -39,6 +39,7 @@ from ZTUtils import make_query
from
Products.ERP5Type.Tool.BaseTool
import
BaseTool
from
Products.ERP5Type.Tool.BaseTool
import
BaseTool
from
Products.ERP5Type
import
Permissions
as
ERP5Permissions
from
Products.ERP5Type
import
Permissions
as
ERP5Permissions
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.Utils
import
str2bytes
from
Products.ERP5Form
import
_dtmldir
from
Products.ERP5Form
import
_dtmldir
from
Products.ERP5Form.Selection
import
Selection
,
DomainSelection
from
Products.ERP5Form.Selection
import
Selection
,
DomainSelection
from
ZPublisher.HTTPRequest
import
FileUpload
from
ZPublisher.HTTPRequest
import
FileUpload
...
@@ -1225,10 +1226,7 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -1225,10 +1226,7 @@ class SelectionTool( BaseTool, SimpleItem ):
return
None
return
None
# XXX To avoid the difference of the string representations of int and long,
# XXX To avoid the difference of the string representations of int and long,
# convert each element to a string.
# convert each element to a string.
if
six
.
PY3
:
return
md5
(
str2bytes
(
repr
(
sorted
(
str
(
e
)
for
e
in
uid_list
)))).
hexdigest
()
return
md5
(
str
(
sorted
(
uid_list
)).
encode
()).
hexdigest
()
else
:
return
md5
(
str
(
sorted
(
map
(
str
,
uid_list
)))).
hexdigest
()
# Related document searching
# Related document searching
security
.
declarePublic
(
'viewSearchRelatedDocumentDialog'
)
security
.
declarePublic
(
'viewSearchRelatedDocumentDialog'
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
276bf142
...
@@ -943,7 +943,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
...
@@ -943,7 +943,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
forced_portal_id
=
os
.
environ
.
get
(
'erp5_tests_portal_id'
)
forced_portal_id
=
os
.
environ
.
get
(
'erp5_tests_portal_id'
)
if
forced_portal_id
:
if
forced_portal_id
:
return
str
(
forced_portal_id
)
return
str
(
forced_portal_id
)
m
=
md5
(
repr
(
self
.
getBusinessTemplateList
())
+
self
.
getTitle
(
))
m
=
md5
(
str2bytes
(
repr
(
self
.
getBusinessTemplateList
())
+
self
.
getTitle
()
))
return
portal_name
+
'_'
+
m
.
hexdigest
()
return
portal_name
+
'_'
+
m
.
hexdigest
()
def
getPortal
(
self
):
def
getPortal
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment