Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
572e180e
Commit
572e180e
authored
Mar 27, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use urllib parse + quote for better url sanitization
parent
55470c04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
utils.py
services/text/utils.py
+7
-1
No files found.
services/text/utils.py
View file @
572e180e
from
sqlite3
import
connect
,
Row
from
sqlite3
import
connect
,
Row
from
re
import
sub
,
match
from
re
import
sub
,
match
from
urllib.parse
import
quote
,
urlparse
,
urlunparse
if
__package__
==
"services.text"
:
if
__package__
==
"services.text"
:
from
services.tools
import
mlog
from
services.tools
import
mlog
...
@@ -32,7 +33,12 @@ def sanitize(value, specific_type=None):
...
@@ -32,7 +33,12 @@ def sanitize(value, specific_type=None):
# NB san_val_bool = bool(san_val)
# NB san_val_bool = bool(san_val)
elif
specific_type
==
"surl"
:
elif
specific_type
==
"surl"
:
san_val
=
sub
(
r'[^\w@\.: /~_+$?=&
%-
\'"]'
,
'_'
,
str_val
)
try
:
san_val
=
urlunparse
(
map
(
quote
,
list
(
urlparse
(
str_val
))))
except
:
mlog
(
"WARNING"
,
"sanitize via urllib couldn't parse url '
%
s', using regexp sanitize instead"
%
str_val
)
san_val
=
sub
(
r'[^\w@\.: /~_+$?=&
%-
]'
,
'_'
,
str_val
)
elif
specific_type
==
"sdate"
:
elif
specific_type
==
"sdate"
:
san_val
=
sub
(
r'[^0-9/-:]'
,
'_'
,
str_val
)
san_val
=
sub
(
r'[^0-9/-:]'
,
'_'
,
str_val
)
...
...
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