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
41232bcd
Commit
41232bcd
authored
Apr 24, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: fix warnings with regex
parent
dd6beed6
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
24 additions
and
24 deletions
+24
-24
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+1
-1
product/ERP5Form/CaptchasDotNet.py
product/ERP5Form/CaptchasDotNet.py
+1
-1
product/ERP5Form/ImageField.py
product/ERP5Form/ImageField.py
+2
-2
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+1
-1
product/ERP5OOo/FormPrintout.py
product/ERP5OOo/FormPrintout.py
+2
-2
product/ERP5OOo/OOoTemplate.py
product/ERP5OOo/OOoTemplate.py
+2
-2
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+1
-1
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+5
-5
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+2
-2
product/ERP5Type/patches/python.py
product/ERP5Type/patches/python.py
+1
-1
product/Formulator/Validator.py
product/Formulator/Validator.py
+1
-1
product/PortalTransforms/libtransforms/commandtransform.py
product/PortalTransforms/libtransforms/commandtransform.py
+1
-1
product/PortalTransforms/transforms/html_to_text.py
product/PortalTransforms/transforms/html_to_text.py
+2
-2
product/PortalTransforms/transforms/safe_html.py
product/PortalTransforms/transforms/safe_html.py
+2
-2
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
41232bcd
...
@@ -1101,7 +1101,7 @@ class TemplateTool (BaseTool):
...
@@ -1101,7 +1101,7 @@ class TemplateTool (BaseTool):
- 1.1 < 2.0
- 1.1 < 2.0
- 1.0.0 = 1.0
- 1.0.0 = 1.0
"""
"""
r = re.compile('
(
\
d
+|
[
a
-
zA
-
Z
])
')
r = re.compile(
r
'
(
\
d
+|
[
a
-
zA
-
Z
])
')
v1 = r.findall(version1)
v1 = r.findall(version1)
v2 = r.findall(version2)
v2 = r.findall(version2)
...
...
product/ERP5Form/CaptchasDotNet.py
View file @
41232bcd
...
@@ -86,7 +86,7 @@ class CaptchasDotNet:
...
@@ -86,7 +86,7 @@ class CaptchasDotNet:
return
url
return
url
def
image
(
self
,
random
,
id
=
'captchas.net'
):
def
image
(
self
,
random
,
id
=
'captchas.net'
):
return
'''
return
r
'''
<img class="captchas_dot_net"
<img class="captchas_dot_net"
id="%(id)s" src="%(source)s" width="%(width)d" height="%(height)d"
id="%(id)s" src="%(source)s" width="%(width)d" height="%(height)d"
alt="The CAPTCHA image" />
alt="The CAPTCHA image" />
...
...
product/ERP5Form/ImageField.py
View file @
41232bcd
...
@@ -215,8 +215,8 @@ class ImageFieldWidget(Widget.TextWidget):
...
@@ -215,8 +215,8 @@ class ImageFieldWidget(Widget.TextWidget):
def
_getPictureSize
(
self
,
picture_width
,
picture_height
,
target_width
,
def
_getPictureSize
(
self
,
picture_width
,
picture_height
,
target_width
,
target_height
):
target_height
):
# if not match causes exception
# if not match causes exception
width_tuple
=
re
.
match
(
"(
\
d[
\
d
\
.]*)(.*)
"
, target_width).groups()
width_tuple
=
re
.
match
(
r
"(\
d[
\d\
.]*)(.*)
", target_width).groups()
height_tuple = re.match("
(
\
d
[
\
d
\
.]
*
)(.
*
)
", target_height).groups()
height_tuple = re.match(
r
"
(
\
d
[
\
d
\
.]
*
)(.
*
)
", target_height).groups()
unit = width_tuple[1]
unit = width_tuple[1]
w = float(width_tuple[0])
w = float(width_tuple[0])
h = float(height_tuple[0])
h = float(height_tuple[0])
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
41232bcd
...
@@ -684,7 +684,7 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -684,7 +684,7 @@ class SelectionTool( BaseTool, SimpleItem ):
# qdsqdsq/Base_view/qsdsqd --> matches
# qdsqdsq/Base_view/qsdsqd --> matches
# qdsqdsq/Base_viewAaa --> doesn't match
# qdsqdsq/Base_viewAaa --> doesn't match
# qdsqdsq/Umpa_view --> doesn't match
# qdsqdsq/Umpa_view --> doesn't match
if
re
.
search
(
'/%s($|
\
W+)
'
% form_id, url):
if
re
.
search
(
r
'/%s($|\
W+)
' % form_id, url):
return form_id
return form_id
return '
view
'
return '
view
'
...
...
product/ERP5OOo/FormPrintout.py
View file @
41232bcd
...
@@ -617,8 +617,8 @@ class ODFStrategy(Implicit):
...
@@ -617,8 +617,8 @@ class ODFStrategy(Implicit):
if
svg_width
is
None
or
svg_height
is
None
:
if
svg_width
is
None
or
svg_height
is
None
:
return
(
'0cm'
,
'0cm'
)
return
(
'0cm'
,
'0cm'
)
# if not match causes exception
# if not match causes exception
width_tuple
=
re
.
match
(
"(
\
d[
\
d
\
.]*)(.*)
"
, svg_width).groups()
width_tuple
=
re
.
match
(
r
"(\
d[
\d\
.]*)(.*)
", svg_width).groups()
height_tuple = re.match("
(
\
d
[
\
d
\
.]
*
)(.
*
)
", svg_height).groups()
height_tuple = re.match(
r
"
(
\
d
[
\
d
\
.]
*
)(.
*
)
", svg_height).groups()
unit = width_tuple[1]
unit = width_tuple[1]
w = Decimal(width_tuple[0])
w = Decimal(width_tuple[0])
h = Decimal(height_tuple[0])
h = Decimal(height_tuple[0])
...
...
product/ERP5OOo/OOoTemplate.py
View file @
41232bcd
...
@@ -278,7 +278,7 @@ class OOoTemplate(ZopePageTemplate):
...
@@ -278,7 +278,7 @@ class OOoTemplate(ZopePageTemplate):
def
renderIncludes
(
self
,
here
,
text
,
extra_context
,
request
,
sub_document
=
None
):
def
renderIncludes
(
self
,
here
,
text
,
extra_context
,
request
,
sub_document
=
None
):
attached_files_dict
=
{}
attached_files_dict
=
{}
arguments_re
=
re
.
compile
(
'''(
\
S+?)
\
s*=
\
s*(
'
|")(.*?)
\
\
2
\
s*
'
'',re.DOTALL)
arguments_re
=
re
.
compile
(
r'''(\
S+?)
\s*=\
s*(
'|")(.*?)
\2\
s*
''',re.DOTALL)
def getLengthInfos( opts_dict, opts_names ):
def getLengthInfos( opts_dict, opts_names ):
ret = []
ret = []
for opt_name in opts_names:
for opt_name in opts_names:
...
@@ -442,7 +442,7 @@ class OOoTemplate(ZopePageTemplate):
...
@@ -442,7 +442,7 @@ class OOoTemplate(ZopePageTemplate):
office_include.getparent().replace(office_include, draw_object)
office_include.getparent().replace(office_include, draw_object)
text = bytes2str(etree.tostring(xml_doc, encoding='utf-8', xml_declaration=True,
text = bytes2str(etree.tostring(xml_doc, encoding='utf-8', xml_declaration=True,
pretty_print=False))
pretty_print=False))
text = re.sub('<
\
s*o
f
fice:include_img
\
s+(.*?)
\
s*/
\
s*>(?s)
'
, replaceIncludesImg, text)
text = re.sub(
r
'<
\
s*o
f
fice:include_img
\
s+(.*?)
\
s*/
\
s*>(?s)
'
, replaceIncludesImg, text)
return (text, attached_files_dict)
return (text, attached_files_dict)
# Proxy method to PageTemplate
# Proxy method to PageTemplate
...
...
product/ERP5Type/Base.py
View file @
41232bcd
...
@@ -128,7 +128,7 @@ class PersistentContainer(Persistent):
...
@@ -128,7 +128,7 @@ class PersistentContainer(Persistent):
self
.
value
=
state
self
.
value
=
state
global
registered_workflow_method_set
global
registered_workflow_method_set
wildcard_interaction_method_id_match
=
re
.
compile
(
r'[[.?*+{(\\]'
).
search
wildcard_interaction_method_id_match
=
re
.
compile
(
r'[
\
[.?*+{(
\\
]
').search
workflow_method_registry = [] # XXX A set() would be better but would require a hash in WorkflowMethod class
workflow_method_registry = [] # XXX A set() would be better but would require a hash in WorkflowMethod class
def resetRegisteredWorkflowMethod(portal_type=None):
def resetRegisteredWorkflowMethod(portal_type=None):
...
...
product/ERP5Type/Utils.py
View file @
41232bcd
...
@@ -462,7 +462,7 @@ def fill_args_from_request(*optional_args):
...
@@ -462,7 +462,7 @@ def fill_args_from_request(*optional_args):
return
decorator
return
decorator
_pylint_message_re
=
re
.
compile
(
_pylint_message_re
=
re
.
compile
(
'^(?P<type>[CRWEF]):
\
s*(?P<
r
ow>
\
d+),
\
s*(?P<column>
\
d+):
\
s*(?P<message>.*)$'
)
r
'^(?P<type>[CRWEF]):\
s*(?P<
row>\
d+),
\s*(?P<column>\
d+):
\s*(?P<message>.*)$'
)
def
checkPythonSourceCode
(
source_code_str
,
portal_type
=
None
):
def
checkPythonSourceCode
(
source_code_str
,
portal_type
=
None
):
"""
"""
...
@@ -762,7 +762,7 @@ from .Accessor.Base import func_code
...
@@ -762,7 +762,7 @@ from .Accessor.Base import func_code
from
Products.CMFCore.utils
import
manage_addContentForm
,
manage_addContent
from
Products.CMFCore.utils
import
manage_addContentForm
,
manage_addContent
from
AccessControl.PermissionRole
import
PermissionRole
from
AccessControl.PermissionRole
import
PermissionRole
python_file_parser
=
re
.
compile
(
'^(.*)
\
.py$
'
)
python_file_parser
=
re
.
compile
(
r
'^(.*)\
.py$
')
def getLocalPropertySheetList():
def getLocalPropertySheetList():
if not getConfiguration:
if not getConfiguration:
...
@@ -1740,12 +1740,12 @@ from six.moves.urllib.parse import urlsplit, urlunsplit, urljoin
...
@@ -1740,12 +1740,12 @@ from six.moves.urllib.parse import urlsplit, urlunsplit, urljoin
# Regular expressions
# Regular expressions
re_cleanup_anchors
=
re
.
compile
(
'#.*'
)
re_cleanup_anchors
=
re
.
compile
(
'#.*'
)
re_extract_port
=
re
.
compile
(
':(
\
d+)$
'
)
re_extract_port
=
re
.
compile
(
r
':(\
d+)$
')
def uppercaseLetter(matchobject):
def uppercaseLetter(matchobject):
return matchobject.group(0).upper()
return matchobject.group(0).upper()
re_cleanup_escaped_url = re.compile('
%
\
w
\
d
')
re_cleanup_escaped_url = re.compile(
r
'
%
\
w
\
d
')
re_cleanup_slashes = re.compile('
/
{
2
,}
')
re_cleanup_slashes = re.compile('
/
{
2
,}
')
re_cleanup_tail = re.compile('
\
??$
')
re_cleanup_tail = re.compile(
r
'
\
??$
')
def legacyNormalizeUrl(url, base_url=None):
def legacyNormalizeUrl(url, base_url=None):
"""this method does normalisation itself.
"""this method does normalisation itself.
...
...
product/ERP5Type/patches/DA.py
View file @
41232bcd
...
@@ -100,7 +100,7 @@ def DA_PUT(self, REQUEST, RESPONSE):
...
@@ -100,7 +100,7 @@ def DA_PUT(self, REQUEST, RESPONSE):
if
RESPONSE
is
not
None
:
self
.
dav__init
(
REQUEST
,
RESPONSE
)
if
RESPONSE
is
not
None
:
self
.
dav__init
(
REQUEST
,
RESPONSE
)
if
RESPONSE
is
not
None
:
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
if
RESPONSE
is
not
None
:
self
.
dav__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
body
=
REQUEST
.
get
(
'BODY'
,
''
)
m
=
re
.
match
(
'
\
s*<d
t
ml-comment>(.*?)</dtml-comment>
\
s*
\
n'
,
body
,
re
.
I
|
re
.
S
)
m
=
re
.
match
(
r
'\
s*<d
tml-comment>(.*?)</dtml-comment>\
s*
\n'
,
body
,
re
.
I
|
re
.
S
)
if
m
:
if
m
:
property_src
=
m
.
group
(
1
)
property_src
=
m
.
group
(
1
)
parameters
=
{}
parameters
=
{}
...
@@ -121,7 +121,7 @@ def DA_PUT(self, REQUEST, RESPONSE):
...
@@ -121,7 +121,7 @@ def DA_PUT(self, REQUEST, RESPONSE):
self
.
title
=
str
(
title
)
self
.
title
=
str
(
title
)
self
.
connection_id
=
str
(
connection_id
)
self
.
connection_id
=
str
(
connection_id
)
body
=
body
[
m
.
end
():]
body
=
body
[
m
.
end
():]
m
=
re
.
match
(
'
\
s*<p
a
rams>(.*)</params>
\
s*
\
n'
,
body
,
re
.
I
|
re
.
S
)
m
=
re
.
match
(
r
'\
s*<p
arams>(.*)</params>\
s*
\n'
,
body
,
re
.
I
|
re
.
S
)
if
m
:
if
m
:
self
.
arguments_src
=
m
.
group
(
1
)
self
.
arguments_src
=
m
.
group
(
1
)
self
.
_arg
=
parse
(
self
.
arguments_src
)
self
.
_arg
=
parse
(
self
.
arguments_src
)
...
...
product/ERP5Type/patches/python.py
View file @
41232bcd
...
@@ -130,7 +130,7 @@ def patch_linecache():
...
@@ -130,7 +130,7 @@ def patch_linecache():
properly without requiring to create a temporary file on the filesystem
properly without requiring to create a temporary file on the filesystem
The filename is is always '<portal_components/*>' for ZODB Components,
The filename is is always '<portal_components/*>' for ZODB Components,
'(FILENAME)?Script
\
(Py
t
hon
\
)
'
for Zope Python Scripts and 'Python
'(FILENAME)?Script
\
\
(Python
\
\
)' for Zope Python Scripts and 'Python
Expression "CODE"' for TALES expressions.
Expression "CODE"' for TALES expressions.
linecache.cache filled by linecache.updatecache() called by the original
linecache.cache filled by linecache.updatecache() called by the original
...
...
product/Formulator/Validator.py
View file @
41232bcd
...
@@ -184,7 +184,7 @@ class EmailValidator(StringValidator):
...
@@ -184,7 +184,7 @@ class EmailValidator(StringValidator):
# brackets around the address (we assume these would be added by
# brackets around the address (we assume these would be added by
# some custom script if needed), and of course no characters that
# some custom script if needed), and of course no characters that
# don't belong in an e-mail address.
# don't belong in an e-mail address.
pattern
=
re
.
compile
(
'^[0-9a-zA-Z_
\
'
&.%+-]+@([0-9a-zA-Z]([0-9a-zA-Z-]*[0-9a-zA-Z])?
\
.)+[
a
-zA-Z]{2,}$'
)
pattern
=
re
.
compile
(
r
'^[0-9a-zA-Z_\'&.%+-]+@([0-9a-zA-Z]([0-9a-zA-Z-]*[0-9a-zA-Z])?\
.)+[
a-zA-Z]{2,}$'
)
def
validate
(
self
,
field
,
key
,
REQUEST
):
def
validate
(
self
,
field
,
key
,
REQUEST
):
value
=
StringValidator
.
validate
(
self
,
field
,
key
,
REQUEST
)
value
=
StringValidator
.
validate
(
self
,
field
,
key
,
REQUEST
)
...
...
product/PortalTransforms/libtransforms/commandtransform.py
View file @
41232bcd
...
@@ -42,7 +42,7 @@ class commandtransform:
...
@@ -42,7 +42,7 @@ class commandtransform:
def
subObjects
(
self
,
tmpdir
):
def
subObjects
(
self
,
tmpdir
):
imgs
=
[]
imgs
=
[]
for
f
in
os
.
listdir
(
tmpdir
):
for
f
in
os
.
listdir
(
tmpdir
):
result
=
re
.
match
(
"^.+
\
.(?P<ex
t
>.+)$"
,
f
)
result
=
re
.
match
(
r
"^.+\
.(?P<ex
t>.+)$"
,
f
)
if
result
is
not
None
:
if
result
is
not
None
:
ext
=
result
.
group
(
'ext'
)
ext
=
result
.
group
(
'ext'
)
if
ext
in
(
'png'
,
'jpg'
,
'gif'
):
if
ext
in
(
'png'
,
'jpg'
,
'gif'
):
...
...
product/PortalTransforms/transforms/html_to_text.py
View file @
41232bcd
...
@@ -26,9 +26,9 @@ def register():
...
@@ -26,9 +26,9 @@ def register():
(
'(?im)<head [^>]>.*</head>'
,
' '
),
(
'(?im)<head [^>]>.*</head>'
,
' '
),
# added for ERP5, we want to transform <br/> in newlines
# added for ERP5, we want to transform <br/> in newlines
(
'(?im)<br
\
s*/?>
'
, '
\
n
'),
(
r
'(?im)<br\
s*/?>
', '
\
n
'),
('
(
?
im
)
</
?
(
font
|
em
|
i
|
strong
|
b
)(
?
=
\
W
)[
^>
]
*>
', ''),
(
r
'
(
?
im
)
</
?
(
font
|
em
|
i
|
strong
|
b
)(
?
=
\
W
)[
^>
]
*>
', ''),
('
(
?
i
)(
?
m
)
<
[
^>
]
*>
', '
'),
('
(
?
i
)(
?
m
)
<
[
^>
]
*>
', '
'),
(r'
&
([
a
-
zA
-
Z0
-
9
#]*?);', sub_func),
(r'
&
([
a
-
zA
-
Z0
-
9
#]*?);', sub_func),
)
)
product/PortalTransforms/transforms/safe_html.py
View file @
41232bcd
...
@@ -175,7 +175,7 @@ def hasScript(s):
...
@@ -175,7 +175,7 @@ def hasScript(s):
def
decode_htmlentities
(
s
):
def
decode_htmlentities
(
s
):
""" XSS code can be hidden with htmlentities """
""" XSS code can be hidden with htmlentities """
entity_pattern
=
re
.
compile
(
"&#(?P<htmlentity>x?
\
w+)?;?
"
)
entity_pattern
=
re
.
compile
(
r
"&#(?P<htmlentity>x?\
w+)?;?
")
s = entity_pattern.sub(decode_htmlentity,s)
s = entity_pattern.sub(decode_htmlentity,s)
return s
return s
...
@@ -190,7 +190,7 @@ def decode_htmlentity(m):
...
@@ -190,7 +190,7 @@ def decode_htmlentity(m):
except ValueError:
except ValueError:
return entity_value
return entity_value
charset_parser = re.compile('charset="
?
(
?
P
<
charset
>
[
^
"]*)"
?
[
\
S
/
]
?
',
charset_parser = re.compile(
r
'charset="
?
(
?
P
<
charset
>
[
^
"]*)"
?
[
\
S
/
]
?
',
re.IGNORECASE)
re.IGNORECASE)
class CharsetReplacer:
class CharsetReplacer:
def __init__(self, encoding):
def __init__(self, encoding):
...
...
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