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
1c11d439
Commit
1c11d439
authored
Apr 24, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: fix warnings with regex
parent
a5a4d0a4
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
23 additions
and
23 deletions
+23
-23
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
+4
-4
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 @
1c11d439
...
...
@@ -1101,7 +1101,7 @@ class TemplateTool (BaseTool):
- 1.1 < 2.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)
v2 = r.findall(version2)
...
...
product/ERP5Form/CaptchasDotNet.py
View file @
1c11d439
...
...
@@ -86,7 +86,7 @@ class CaptchasDotNet:
return
url
def
image
(
self
,
random
,
id
=
'captchas.net'
):
return
'''
return
r
'''
<img class="captchas_dot_net"
id="%(id)s" src="%(source)s" width="%(width)d" height="%(height)d"
alt="The CAPTCHA image" />
...
...
product/ERP5Form/ImageField.py
View file @
1c11d439
...
...
@@ -215,8 +215,8 @@ class ImageFieldWidget(Widget.TextWidget):
def
_getPictureSize
(
self
,
picture_width
,
picture_height
,
target_width
,
target_height
):
# if not match causes exception
width_tuple
=
re
.
match
(
"(
\
d[
\
d
\
.]*)(.*)
"
, target_width).groups()
height_tuple = re.match("
(
\
d
[
\
d
\
.]
*
)(.
*
)
", target_height).groups()
width_tuple
=
re
.
match
(
r
"(\
d[
\d\
.]*)(.*)
", target_width).groups()
height_tuple = re.match(
r
"
(
\
d
[
\
d
\
.]
*
)(.
*
)
", target_height).groups()
unit = width_tuple[1]
w = float(width_tuple[0])
h = float(height_tuple[0])
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
1c11d439
...
...
@@ -684,7 +684,7 @@ class SelectionTool( BaseTool, SimpleItem ):
# qdsqdsq/Base_view/qsdsqd --> matches
# qdsqdsq/Base_viewAaa --> 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 '
view
'
...
...
product/ERP5OOo/FormPrintout.py
View file @
1c11d439
...
...
@@ -617,8 +617,8 @@ class ODFStrategy(Implicit):
if
svg_width
is
None
or
svg_height
is
None
:
return
(
'0cm'
,
'0cm'
)
# if not match causes exception
width_tuple
=
re
.
match
(
"(
\
d[
\
d
\
.]*)(.*)
"
, svg_width).groups()
height_tuple = re.match("
(
\
d
[
\
d
\
.]
*
)(.
*
)
", svg_height).groups()
width_tuple
=
re
.
match
(
r
"(\
d[
\d\
.]*)(.*)
", svg_width).groups()
height_tuple = re.match(
r
"
(
\
d
[
\
d
\
.]
*
)(.
*
)
", svg_height).groups()
unit = width_tuple[1]
w = Decimal(width_tuple[0])
h = Decimal(height_tuple[0])
...
...
product/ERP5OOo/OOoTemplate.py
View file @
1c11d439
...
...
@@ -278,7 +278,7 @@ class OOoTemplate(ZopePageTemplate):
def
renderIncludes
(
self
,
here
,
text
,
extra_context
,
request
,
sub_document
=
None
):
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 ):
ret = []
for opt_name in opts_names:
...
...
@@ -442,7 +442,7 @@ class OOoTemplate(ZopePageTemplate):
office_include.getparent().replace(office_include, draw_object)
text = bytes2str(etree.tostring(xml_doc, encoding='utf-8', xml_declaration=True,
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)
# Proxy method to PageTemplate
...
...
product/ERP5Type/Base.py
View file @
1c11d439
...
...
@@ -128,7 +128,7 @@ class PersistentContainer(Persistent):
self
.
value
=
state
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
def resetRegisteredWorkflowMethod(portal_type=None):
...
...
product/ERP5Type/Utils.py
View file @
1c11d439
...
...
@@ -772,7 +772,7 @@ from .Accessor.Base import func_code
from
Products.CMFCore.utils
import
manage_addContentForm
,
manage_addContent
from
AccessControl.PermissionRole
import
PermissionRole
python_file_parser
=
re
.
compile
(
'^(.*)
\
.py$
'
)
python_file_parser
=
re
.
compile
(
r
'^(.*)\
.py$
')
def getLocalPropertySheetList():
if not getConfiguration:
...
...
@@ -1750,12 +1750,12 @@ from six.moves.urllib.parse import urlsplit, urlunsplit, urljoin
# Regular expressions
re_cleanup_anchors
=
re
.
compile
(
'#.*'
)
re_extract_port
=
re
.
compile
(
':(
\
d+)$
'
)
re_extract_port
=
re
.
compile
(
r
':(\
d+)$
')
def uppercaseLetter(matchobject):
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_tail = re.compile('
\
??$
')
re_cleanup_tail = re.compile(
r
'
\
??$
')
def legacyNormalizeUrl(url, base_url=None):
"""this method does normalisation itself.
...
...
product/ERP5Type/patches/DA.py
View file @
1c11d439
...
...
@@ -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__simpleifhandler
(
REQUEST
,
RESPONSE
,
refresh
=
1
)
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
:
property_src
=
m
.
group
(
1
)
parameters
=
{}
...
...
@@ -121,7 +121,7 @@ def DA_PUT(self, REQUEST, RESPONSE):
self
.
title
=
str
(
title
)
self
.
connection_id
=
str
(
connection_id
)
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
:
self
.
arguments_src
=
m
.
group
(
1
)
self
.
_arg
=
parse
(
self
.
arguments_src
)
...
...
product/ERP5Type/patches/python.py
View file @
1c11d439
...
...
@@ -130,7 +130,7 @@ def patch_linecache():
properly without requiring to create a temporary file on the filesystem
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.
linecache.cache filled by linecache.updatecache() called by the original
...
...
product/Formulator/Validator.py
View file @
1c11d439
...
...
@@ -184,7 +184,7 @@ class EmailValidator(StringValidator):
# brackets around the address (we assume these would be added by
# some custom script if needed), and of course no characters that
# 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
):
value
=
StringValidator
.
validate
(
self
,
field
,
key
,
REQUEST
)
...
...
product/PortalTransforms/libtransforms/commandtransform.py
View file @
1c11d439
...
...
@@ -42,7 +42,7 @@ class commandtransform:
def
subObjects
(
self
,
tmpdir
):
imgs
=
[]
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
:
ext
=
result
.
group
(
'ext'
)
if
ext
in
(
'png'
,
'jpg'
,
'gif'
):
...
...
product/PortalTransforms/transforms/html_to_text.py
View file @
1c11d439
...
...
@@ -26,9 +26,9 @@ def register():
(
'(?im)<head [^>]>.*</head>'
,
' '
),
# 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
)
<
[
^>
]
*>
', '
'),
(r'
&
([
a
-
zA
-
Z0
-
9
#]*?);', sub_func),
)
product/PortalTransforms/transforms/safe_html.py
View file @
1c11d439
...
...
@@ -175,7 +175,7 @@ def hasScript(s):
def
decode_htmlentities
(
s
):
""" 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)
return s
...
...
@@ -190,7 +190,7 @@ def decode_htmlentity(m):
except ValueError:
return entity_value
charset_parser = re.compile('charset="
?
(
?
P
<
charset
>
[
^
"]*)"
?
[
\
S
/
]
?
',
charset_parser = re.compile(
r
'charset="
?
(
?
P
<
charset
>
[
^
"]*)"
?
[
\
S
/
]
?
',
re.IGNORECASE)
class CharsetReplacer:
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