Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Access Check - Account manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Access Check - Account manager
Commits
bdb22db1
Commit
bdb22db1
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
test parameter format in dedicated handler
parent
fc788d00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/AccountManager/App.pm
+18
-31
18 additions, 31 deletions
lib/AccountManager/App.pm
with
18 additions
and
31 deletions
lib/AccountManager/App.pm
+
18
−
31
View file @
bdb22db1
...
...
@@ -19,17 +19,11 @@ use AccountManager::Service;
use
AccountManager::
Token
;
use
AccountManager::
Tools
;
## Defining parameters format
my
$urn_or_url_regex
=
'
(http(s?):\/\/|urn:)[^
\\
\$\*\"
\'
\`\^\|\<\>\n\s]+
'
;
## Format de type URL HTTP ou URN
my
$url_regex
=
'
http(s?):\/\/[^
\\
\$\*\"
\'
\`\^\|\<\>\n\s]+
';
my
$email_regex
=
'
([\w\-\_\.\/\+\=
\'
\&]+|\".*\")\@[\w\-]+(\.[\w\-]+)+
';
my
$domains_regex
=
'
[\w\.\-]+(,[\w\.\-]+)*
';
my
%format
=
(
## URL
#'attributeauthority' => $url_regex,
'
entityid
'
=>
$urn_or_url_regex
,
);
# Format de type URL HTTP ou URN
my
$urn_or_url_regex
=
'
(http(s?):\/\/|urn:)[^
\\
\$\*\"
\'
\`\^\|\<\>\n\s]+
';
my
$url_regex
=
'
http(s?):\/\/[^
\\
\$\*\"
\'
\`\^\|\<\>\n\s]+
';
my
$email_regex
=
'
([\w\-\_\.\/\+\=
\'
\&]+|\".*\")\@[\w\-]+(\.[\w\-]+)+
';
my
$domains_regex
=
'
[\w\.\-]+(,[\w\.\-]+)*
';
my
%actions
=
(
home
=>
'
req_home
',
...
...
@@ -85,23 +79,6 @@ sub run {
$parameters
{
$parameter
}
=~
s/\s+$//
;
# remove trailing spaces
$parameters
{
$parameter
}
=~
s/^\s+//
;
# remove leading spaces
# format check
if
(
defined
$format
{
$parameter
}
&&
!
ref
(
$format
{
$parameter
}))
{
if
(
$parameters
{
$parameter
}
!~
/^$format{$parameter}$/
)
{
$self
->
{
logger
}
->
error
(
"
Incorrect parameter format :
$parameter
"
);
$self
->
respond
(
template
=>
'
index.tt2.html
',
data
=>
{
content
=>
'
errors.tt2.html
',
errors
=>
[
"
format_
$parameter
"
]
}
);
}
}
# If action_xx parameter is set, set action parameter with value xx
if
(
$parameter
=~
/^action_(\w+)$/
)
{
$parameters
{
action
}
=
$
1
;
...
...
@@ -168,7 +145,6 @@ sub respond {
printf
"
Content-type: text/plain
\n\n
Error: %s
",
$tt2
->
error
();
$self
->
{
logger
}
->
errorf
("
Web parser error : %s
",
$tt2
->
error
());
}
}
sub
req_select_sp
{
...
...
@@ -207,8 +183,8 @@ sub req_select_sp {
sub
req_select_email
{
my
(
$self
)
=
@_
;
unless
(
$self
->
{
in
}
->
{
entityid
})
{
$self
->
{
logger
}
->
error
("
Missing parameter entityid
");
if
(
!
$self
->
{
in
}
->
{
entityid
})
{
$self
->
{
logger
}
->
error
("
Missing parameter
:
entityid
");
$self
->
respond
(
template
=>
'
index-nobanner.tt2.html
',
data
=>
{
...
...
@@ -218,6 +194,17 @@ sub req_select_email {
);
}
if
(
$self
->
{
in
}
->
{
entityid
}
!~
m/^$urn_or_url_regex$/
)
{
$self
->
{
logger
}
->
error
("
Incorrect parameter format: entityid
");
$self
->
respond
(
template
=>
'
index-nobanner.tt2.html
',
data
=>
{
content
=>
'
errors.tt2.html
',
errors
=>
[
"
format_entityid
"
]
}
);
}
# Create a persistent service provider object
my
$provider
=
AccountManager::
Service
->
new
(
db
=>
$self
->
{
db
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment