Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
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
David Youssefi
otb
Commits
df5c7ae9
Commit
df5c7ae9
authored
10 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: allow application keys beginning with a number
parent
ca99b934
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
Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx
+23
-5
23 additions, 5 deletions
Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx
with
23 additions
and
5 deletions
Code/Wrappers/CommandLine/otbWrapperCommandLineParser.cxx
+
23
−
5
View file @
df5c7ae9
...
...
@@ -92,6 +92,11 @@ CommandLineParser::GetPathsAsString( const std::string & exp )
CommandLineParser
::
ParseResultType
CommandLineParser
::
GetPaths
(
std
::
vector
<
std
::
string
>
&
paths
,
const
std
::
vector
<
std
::
string
>
&
exp
)
{
if
(
exp
.
empty
())
{
return
NOMODULEPATH
;
}
// The first element must be the module name, non " -" allowed.
// The module path list elements are the strings between the first
// element and the first key (ie. string which begins with "-").
...
...
@@ -180,6 +185,11 @@ CommandLineParser::GetPaths( std::vector<std::string> & paths, const std::string
CommandLineParser
::
ParseResultType
CommandLineParser
::
GetModuleName
(
std
::
string
&
modName
,
const
std
::
vector
<
std
::
string
>
&
exp
)
{
if
(
exp
.
empty
())
{
return
NOMODULENAME
;
}
itksys
::
RegularExpression
reg
;
reg
.
compile
(
"([^0-9a-zA-Z])"
);
// The first element must be the module path, non " -" allowed.
...
...
@@ -521,19 +531,27 @@ CommandLineParser::IsAValidKey( const std::string & foundKey )
tmp
.
append
(
"."
);
// To be a key, the string must be a serie of groups separated by dots so that :
// - each group
begins with an lower case let
ter
// - each group
has at least one charac
ter
// - each group contains only alphanumeric characters (and lowercase)
// This also implies that each group is not empty and that the key doesn't
// start with a dot. These conditions shouldn't match any number even in
// scientific notation.
// - there is at least one group
// The following regular expression says just that
itksys
::
RegularExpression
reg
;
reg
.
compile
(
"^([a-
z][a-
z0-9]
*
\\
.)+$"
);
reg
.
compile
(
"^([a-z0-9]
+
\\
.)+$"
);
if
(
reg
.
find
(
tmp
)
)
{
res
=
true
;
}
// a second test is performed to detect negative numbers (even in
// scientific notation). Any key that matches the search pattern for a
// number is considered not valid.
itksys
::
RegularExpression
regNum
;
regNum
.
compile
(
"^([0-9]+(
\\
.[0-9]*)?([eE][+-]?[0-9]+)?)$"
);
if
(
regNum
.
find
(
foundKey
)
)
{
res
=
false
;
}
return
res
;
}
...
...
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