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
42e88f2e
Commit
42e88f2e
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
process input parameters only once
parent
e5fd5a87
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/IdPAccountManager/WebRequest.pm
+41
-48
41 additions, 48 deletions
lib/IdPAccountManager/WebRequest.pm
with
41 additions
and
48 deletions
lib/IdPAccountManager/WebRequest.pm
+
41
−
48
View file @
42e88f2e
...
...
@@ -41,45 +41,7 @@ sub new {
);
$self
->
{
db
}
=
IdPAccountManager::
DB
->
new
();
my
$http_query
=
CGI
->
new
();
## Input parameters
my
%in_vars
=
$http_query
->
Vars
;
$self
->
{
param_in
}
=
\
%in_vars
;
## Usefull data for output (web pages or mail notices)
$self
->
{
param_out
}
->
{
url_cgi
}
=
$ENV
{
SCRIPT_NAME
};
$self
->
{
param_out
}
->
{
env
}
=
\
%ENV
;
$self
->
{
param_out
}
->
{
actions
}
=
$args
{
actions
};
$self
->
{
param_out
}
->
{
conf
}
=
$self
->
{
configuration
};
## Clean input vars
foreach
my
$key
(
keys
%
{
$self
->
{
param_in
}
})
{
## Removing all ^M (0D)
$self
->
{
param_in
}
->
{
$key
}
=~
s/\r//g
;
$self
->
{
param_in
}
->
{
$key
}
=~
s/\s+$//
;
## Remove trailing spaces
$self
->
{
param_in
}
->
{
$key
}
=~
s/^\s+//
;
## Remove leading spaces
## If action_xx param is set, then action=xx
## Usefull to have sementicless values in submit forms
if
(
$key
=~
/^action_(\w+)$/
)
{
#$self->{logger}->log(level => LOG_TRACE, message => "ACTION $key");
$self
->
{
param_in
}
->
{
action
}
=
$
1
;
}
}
## Check the requested action
if
(
$self
->
{
param_in
}
->
{
action
})
{
$self
->
{
action
}
=
$self
->
{
param_in
}
->
{
action
};
}
else
{
## Default action
$self
->
{
logger
}
->
log
(
level
=>
LOG_INFO
,
message
=>
'
Default action
');
$self
->
{
action
}
=
'
home
';
}
$self
->
{
cgi
}
=
CGI
->
new
();
bless
$self
,
$pkg
;
...
...
@@ -93,23 +55,54 @@ sub execute {
my
$status
;
## Check input parameters format
foreach
my
$key
(
keys
%
{
$self
->
{
param_in
}
})
{
if
(
$self
->
{
param_in
}
->
{
$key
}
!~
/^\s*$/
&&
defined
$self
->
{
format
}
->
{
$key
}
&&
!
ref
(
$self
->
{
format
}
->
{
$key
}))
{
unless
(
$self
->
{
param_in
}
->
{
$key
}
=~
/^$self->format->{$key}$/
)
{
push
@
{
$self
->
{
param_out
}
->
{
errors
}
},
"
format_
$key
";
# initialize output parameters
$self
->
{
param_out
}
=
{
url_cgi
=>
$ENV
{
SCRIPT_NAME
},
env
=>
\
%ENV
,
actions
=>
$self
->
{
actions
},
conf
=>
$self
->
{
configuration
},
};
# process input parameters
my
%parameters
=
$self
->
{
cgi
}
->
Vars
();
foreach
my
$parameter
(
keys
%parameters
)
{
# cleanup
$parameters
{
$parameter
}
=~
s/\r//g
;
# remove &0D char
$parameters
{
$parameter
}
=~
s/\s+$//
;
# remove trailing spaces
$parameters
{
$parameter
}
=~
s/^\s+//
;
# remove leading spaces
# format check
if
(
defined
$self
->
{
format
}
->
{
$parameter
}
&&
!
ref
(
$self
->
{
format
}
->
{
$parameter
}))
{
if
(
$parameters
{
$parameter
}
!~
/^$self->format->{$parameter}$/
)
{
push
@
{
$self
->
{
param_out
}
->
{
errors
}
},
"
format_
$parameter
";
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Incorrect parameter format :
$
key
"
message
=>
"
Incorrect parameter format :
$
parameter
"
);
return
undef
;
}
}
# If action_xx parameter is set, set action parameter with value xx
if
(
$parameter
=~
/^action_(\w+)$/
)
{
$parameters
{
action
}
=
$
1
;
}
# register needed parameters
$self
->
{
param_in
}
=
{
email_adress
=>
$parameters
{
action
},
style
=>
$parameters
{
style
},
sp_entityid
=>
$parameters
{
sp_entityid
},
authentication_token
=>
$parameters
{
authentication_token
}
};
}
# Check the requested action
$self
->
{
action
}
=
$parameters
{
action
}
||
'
home
';
do
{
## Actions can be chained
$self
->
{
action
}
=
$self
->
{
next_action
}
if
(
$self
->
{
next_action
});
...
...
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