Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
9231c734
Commit
9231c734
authored
Mar 12, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
match_prefix -> mg_match_prefix
parent
20cb3a82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
mongoose.c
mongoose.c
+17
-15
No files found.
mongoose.c
View file @
9231c734
...
@@ -2139,14 +2139,14 @@ const char *mg_get_header(const struct mg_connection *ri, const char *s) {
...
@@ -2139,14 +2139,14 @@ const char *mg_get_header(const struct mg_connection *ri, const char *s) {
#ifndef MONGOOSE_NO_FILESYSTEM
#ifndef MONGOOSE_NO_FILESYSTEM
// Perform case-insensitive match of string against pattern
// Perform case-insensitive match of string against pattern
static
int
match_prefix
(
const
char
*
pattern
,
int
pattern_len
,
const
char
*
str
)
{
int
mg_
match_prefix
(
const
char
*
pattern
,
int
pattern_len
,
const
char
*
str
)
{
const
char
*
or_str
;
const
char
*
or_str
;
int
len
,
res
,
i
=
0
,
j
=
0
;
int
len
,
res
,
i
=
0
,
j
=
0
;
if
((
or_str
=
(
const
char
*
)
memchr
(
pattern
,
'|'
,
pattern_len
))
!=
NULL
)
{
if
((
or_str
=
(
const
char
*
)
memchr
(
pattern
,
'|'
,
pattern_len
))
!=
NULL
)
{
res
=
match_prefix
(
pattern
,
or_str
-
pattern
,
str
);
res
=
m
g_m
atch_prefix
(
pattern
,
or_str
-
pattern
,
str
);
return
res
>
0
?
res
:
return
res
>
0
?
res
:
mg_match_prefix
(
or_str
+
1
,
match_prefix
(
or_str
+
1
,
(
pattern
+
pattern_len
)
-
(
or_str
+
1
),
str
);
(
pattern
+
pattern_len
)
-
(
or_str
+
1
),
str
);
}
}
for
(;
i
<
pattern_len
;
i
++
,
j
++
)
{
for
(;
i
<
pattern_len
;
i
++
,
j
++
)
{
...
@@ -2166,7 +2166,7 @@ static int match_prefix(const char *pattern, int pattern_len, const char *str) {
...
@@ -2166,7 +2166,7 @@ static int match_prefix(const char *pattern, int pattern_len, const char *str) {
return
j
+
len
;
return
j
+
len
;
}
}
do
{
do
{
res
=
match_prefix
(
pattern
+
i
,
pattern_len
-
i
,
str
+
j
+
len
);
res
=
m
g_m
atch_prefix
(
pattern
+
i
,
pattern_len
-
i
,
str
+
j
+
len
);
}
while
(
res
==
-
1
&&
len
--
>
0
);
}
while
(
res
==
-
1
&&
len
--
>
0
);
return
res
==
-
1
?
-
1
:
j
+
res
+
len
;
return
res
==
-
1
?
-
1
:
j
+
res
+
len
;
}
else
if
(
lowercase
(
&
pattern
[
i
])
!=
lowercase
(
&
str
[
j
]))
{
}
else
if
(
lowercase
(
&
pattern
[
i
])
!=
lowercase
(
&
str
[
j
]))
{
...
@@ -2179,8 +2179,8 @@ static int match_prefix(const char *pattern, int pattern_len, const char *str) {
...
@@ -2179,8 +2179,8 @@ static int match_prefix(const char *pattern, int pattern_len, const char *str) {
static
int
must_hide_file
(
struct
connection
*
conn
,
const
char
*
path
)
{
static
int
must_hide_file
(
struct
connection
*
conn
,
const
char
*
path
)
{
const
char
*
pw_pattern
=
"**"
PASSWORDS_FILE_NAME
"$"
;
const
char
*
pw_pattern
=
"**"
PASSWORDS_FILE_NAME
"$"
;
const
char
*
pattern
=
conn
->
server
->
config_options
[
HIDE_FILES_PATTERN
];
const
char
*
pattern
=
conn
->
server
->
config_options
[
HIDE_FILES_PATTERN
];
return
match_prefix
(
pw_pattern
,
strlen
(
pw_pattern
),
path
)
>
0
||
return
m
g_m
atch_prefix
(
pw_pattern
,
strlen
(
pw_pattern
),
path
)
>
0
||
(
pattern
!=
NULL
&&
match_prefix
(
pattern
,
strlen
(
pattern
),
path
)
>
0
);
(
pattern
!=
NULL
&&
m
g_m
atch_prefix
(
pattern
,
strlen
(
pattern
),
path
)
>
0
);
}
}
// Return 1 if real file has been found, 0 otherwise
// Return 1 if real file has been found, 0 otherwise
...
@@ -2219,7 +2219,7 @@ static int convert_uri_to_file_name(struct connection *conn, char *buf,
...
@@ -2219,7 +2219,7 @@ static int convert_uri_to_file_name(struct connection *conn, char *buf,
mg_snprintf
(
buf
,
buf_len
,
"%.*s%s"
,
root_len
,
root
,
uri
);
mg_snprintf
(
buf
,
buf_len
,
"%.*s%s"
,
root_len
,
root
,
uri
);
rewrites
=
conn
->
server
->
config_options
[
URL_REWRITES
];
// Re-initialize!
rewrites
=
conn
->
server
->
config_options
[
URL_REWRITES
];
// Re-initialize!
while
((
rewrites
=
next_option
(
rewrites
,
&
a
,
&
b
))
!=
NULL
)
{
while
((
rewrites
=
next_option
(
rewrites
,
&
a
,
&
b
))
!=
NULL
)
{
if
((
match_len
=
match_prefix
(
a
.
ptr
,
a
.
len
,
uri
))
>
0
)
{
if
((
match_len
=
m
g_m
atch_prefix
(
a
.
ptr
,
a
.
len
,
uri
))
>
0
)
{
mg_snprintf
(
buf
,
buf_len
,
"%.*s%s"
,
(
int
)
b
.
len
,
b
.
ptr
,
uri
+
match_len
);
mg_snprintf
(
buf
,
buf_len
,
"%.*s%s"
,
(
int
)
b
.
len
,
b
.
ptr
,
uri
+
match_len
);
break
;
break
;
}
}
...
@@ -2232,7 +2232,8 @@ static int convert_uri_to_file_name(struct connection *conn, char *buf,
...
@@ -2232,7 +2232,8 @@ static int convert_uri_to_file_name(struct connection *conn, char *buf,
for
(
p
=
buf
+
strlen
(
root
)
+
2
;
*
p
!=
'\0'
;
p
++
)
{
for
(
p
=
buf
+
strlen
(
root
)
+
2
;
*
p
!=
'\0'
;
p
++
)
{
if
(
*
p
==
'/'
)
{
if
(
*
p
==
'/'
)
{
*
p
=
'\0'
;
*
p
=
'\0'
;
if
(
match_prefix
(
cgi_pat
,
strlen
(
cgi_pat
),
buf
)
>
0
&&
!
stat
(
buf
,
st
))
{
if
(
mg_match_prefix
(
cgi_pat
,
strlen
(
cgi_pat
),
buf
)
>
0
&&
!
stat
(
buf
,
st
))
{
DBG
((
"!!!! [%s]"
,
buf
));
DBG
((
"!!!! [%s]"
,
buf
));
*
p
=
'/'
;
*
p
=
'/'
;
conn
->
path_info
=
mg_strdup
(
p
);
conn
->
path_info
=
mg_strdup
(
p
);
...
@@ -3998,7 +3999,8 @@ static void do_ssi_include(struct mg_connection *conn, const char *ssi,
...
@@ -3998,7 +3999,8 @@ static void do_ssi_include(struct mg_connection *conn, const char *ssi,
tag
,
path
,
strerror
(
errno
));
tag
,
path
,
strerror
(
errno
));
}
else
{
}
else
{
ns_set_close_on_exec
(
fileno
(
fp
));
ns_set_close_on_exec
(
fileno
(
fp
));
if
(
match_prefix
(
opts
[
SSI_PATTERN
],
strlen
(
opts
[
SSI_PATTERN
]),
path
)
>
0
)
{
if
(
mg_match_prefix
(
opts
[
SSI_PATTERN
],
strlen
(
opts
[
SSI_PATTERN
]),
path
)
>
0
)
{
send_ssi_file
(
conn
,
path
,
fp
,
include_level
+
1
);
send_ssi_file
(
conn
,
path
,
fp
,
include_level
+
1
);
}
else
{
}
else
{
send_file_data
(
conn
,
fp
);
send_file_data
(
conn
,
fp
);
...
@@ -4200,20 +4202,20 @@ static void open_local_endpoint(struct connection *conn, int skip_user) {
...
@@ -4200,20 +4202,20 @@ static void open_local_endpoint(struct connection *conn, int skip_user) {
}
else
{
}
else
{
send_http_error
(
conn
,
403
,
NULL
);
send_http_error
(
conn
,
403
,
NULL
);
}
}
}
else
if
(
match_prefix
(
lua_pat
,
sizeof
(
lua_pat
)
-
1
,
path
)
>
0
)
{
}
else
if
(
m
g_m
atch_prefix
(
lua_pat
,
sizeof
(
lua_pat
)
-
1
,
path
)
>
0
)
{
#ifdef MONGOOSE_USE_LUA
#ifdef MONGOOSE_USE_LUA
handle_lsp_request
(
conn
,
path
,
&
st
);
handle_lsp_request
(
conn
,
path
,
&
st
);
#else
#else
send_http_error
(
conn
,
501
,
NULL
);
send_http_error
(
conn
,
501
,
NULL
);
#endif
#endif
}
else
if
(
match_prefix
(
cgi_pat
,
strlen
(
cgi_pat
),
path
)
>
0
)
{
}
else
if
(
m
g_m
atch_prefix
(
cgi_pat
,
strlen
(
cgi_pat
),
path
)
>
0
)
{
#if !defined(MONGOOSE_NO_CGI)
#if !defined(MONGOOSE_NO_CGI)
open_cgi_endpoint
(
conn
,
path
);
open_cgi_endpoint
(
conn
,
path
);
#else
#else
send_http_error
(
conn
,
501
,
NULL
);
send_http_error
(
conn
,
501
,
NULL
);
#endif // !MONGOOSE_NO_CGI
#endif // !MONGOOSE_NO_CGI
#ifndef MONGOOSE_NO_SSI
#ifndef MONGOOSE_NO_SSI
}
else
if
(
match_prefix
(
conn
->
server
->
config_options
[
SSI_PATTERN
],
}
else
if
(
m
g_m
atch_prefix
(
conn
->
server
->
config_options
[
SSI_PATTERN
],
strlen
(
conn
->
server
->
config_options
[
SSI_PATTERN
]),
strlen
(
conn
->
server
->
config_options
[
SSI_PATTERN
]),
path
)
>
0
)
{
path
)
>
0
)
{
handle_ssi_request
(
conn
,
path
);
handle_ssi_request
(
conn
,
path
);
...
...
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