Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
schwede
openstructure
Commits
6e54618d
Commit
6e54618d
authored
13 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
properly escape special characters in glob pattern
parent
ac1e0c09
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/base/src/impl/query_ast.cc
+10
-5
10 additions, 5 deletions
modules/mol/base/src/impl/query_ast.cc
modules/mol/base/src/impl/query_impl.cc
+3
-2
3 additions, 2 deletions
modules/mol/base/src/impl/query_impl.cc
with
13 additions
and
7 deletions
modules/mol/base/src/impl/query_ast.cc
+
10
−
5
View file @
6e54618d
...
@@ -120,6 +120,7 @@ StringOrRegexParam::StringOrRegexParam():
...
@@ -120,6 +120,7 @@ StringOrRegexParam::StringOrRegexParam():
StringOrRegexParam
::
StringOrRegexParam
(
const
String
&
s
)
:
StringOrRegexParam
::
StringOrRegexParam
(
const
String
&
s
)
:
is_regex_
(
false
),
r_
(),
s_
(
s
)
is_regex_
(
false
),
r_
(),
s_
(
s
)
{
{
String
special
(
"[]{}()"
);
for
(
String
::
const_iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
++
it
)
{
for
(
String
::
const_iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
++
it
)
{
if
((
*
it
)
==
'?'
||
(
*
it
)
==
'*'
)
{
if
((
*
it
)
==
'?'
||
(
*
it
)
==
'*'
)
{
is_regex_
=
true
;
is_regex_
=
true
;
...
@@ -130,12 +131,16 @@ StringOrRegexParam::StringOrRegexParam(const String& s):
...
@@ -130,12 +131,16 @@ StringOrRegexParam::StringOrRegexParam(const String& s):
if
(
is_regex_
)
{
if
(
is_regex_
)
{
std
::
ostringstream
e
;
std
::
ostringstream
e
;
for
(
String
::
const_iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
++
it
)
{
for
(
String
::
const_iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
++
it
)
{
if
((
*
it
)
==
'?'
)
{
e
<<
"."
;
if
((
*
it
)
==
'?'
&&
(
it
==
s
.
begin
()
||
(
*
(
it
-
1
))
!=
'\\'
))
{
}
else
if
((
*
it
)
==
'*'
)
{
e
<<
"."
;
e
<<
".*"
;
}
else
if
((
*
it
)
==
'*'
&&
(
it
==
s
.
begin
()
||
(
*
(
it
-
1
))
!=
'\\'
))
{
e
<<
".*"
;
}
else
{
}
else
{
e
<<
*
it
;
if
(
special
.
find
(
*
it
)
!=
String
::
npos
)
{
e
<<
'\\'
;
}
e
<<
*
it
;
}
}
}
}
//std::cerr << "assembling regex [" << e.str() << "]... ";
//std::cerr << "assembling regex [" << e.str() << "]... ";
...
...
This diff is collapsed.
Click to expand it.
modules/mol/base/src/impl/query_impl.cc
+
3
−
2
View file @
6e54618d
...
@@ -148,7 +148,7 @@ QueryToken QueryLexer::LexNumericToken() {
...
@@ -148,7 +148,7 @@ QueryToken QueryLexer::LexNumericToken() {
}
}
bool
is_ident_or_str
(
char
c
)
{
bool
is_ident_or_str
(
char
c
)
{
static
String
allowed_chars
(
"_*?"
);
static
String
allowed_chars
(
"_*?
\\
"
);
return
isalnum
(
c
)
||
allowed_chars
.
find_first_of
(
c
)
!=
String
::
npos
;
return
isalnum
(
c
)
||
allowed_chars
.
find_first_of
(
c
)
!=
String
::
npos
;
}
}
...
@@ -158,7 +158,8 @@ QueryToken QueryLexer::LexIdentOrStringToken() {
...
@@ -158,7 +158,8 @@ QueryToken QueryLexer::LexIdentOrStringToken() {
bool
force_string
=
false
;
bool
force_string
=
false
;
while
(
current_
<
query_string_
.
length
()
&&
while
(
current_
<
query_string_
.
length
()
&&
is_ident_or_str
(
query_string_
[
current_
]))
{
is_ident_or_str
(
query_string_
[
current_
]))
{
if
(
query_string_
[
current_
]
==
'*'
||
query_string_
[
current_
]
==
'?'
)
{
if
(
query_string_
[
current_
]
==
'*'
||
query_string_
[
current_
]
==
'?'
||
query_string_
[
current_
]
==
'\\'
)
{
force_string
=
true
;
force_string
=
true
;
}
}
current_
++
;
current_
++
;
...
...
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