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
d864d724
Commit
d864d724
authored
Jul 17, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On windows, enclosing path to CGI script in quotes to allow paths with spaces
parent
7ca5962d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
mongoose.c
mongoose.c
+1
-1
hello.cgi
test/dir with spaces/hello.cgi
+3
-0
test.pl
test/test.pl
+13
-11
No files found.
mongoose.c
View file @
d864d724
...
...
@@ -1341,7 +1341,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
}
GetFullPathNameA
(
dir
,
sizeof
(
full_dir
),
full_dir
,
NULL
);
mg_snprintf
(
conn
,
cmdline
,
sizeof
(
cmdline
),
"%s%s
%s
\\
%s
"
,
mg_snprintf
(
conn
,
cmdline
,
sizeof
(
cmdline
),
"%s%s
\"
%s
\\
%s
\"
"
,
interp
,
interp
[
0
]
==
'\0'
?
""
:
" "
,
full_dir
,
prog
);
DEBUG_TRACE
((
"Running [%s]"
,
cmdline
));
...
...
test/dir with spaces/hello.cgi
0 → 100755
View file @
d864d724
#!/usr/bin/env perl
print
"Content-Type: text/plain\n\nhello\n"
;
test/test.pl
View file @
d864d724
...
...
@@ -19,9 +19,10 @@ my $test_dir_uri = "test_dir";
my
$root
=
'test'
;
my
$test_dir
=
$root
.
$dir_separator
.
$test_dir_uri
;
my
$config
=
'mongoose.conf'
;
my
$exe
=
'.'
.
$dir_separator
.
'mongoose'
;
my
$embed_exe
=
'.'
.
$dir_separator
.
'embed'
;
my
$unit_test_exe
=
'.'
.
$dir_separator
.
'unit_test'
;
my
$exe_ext
=
on_windows
()
?
'.exe'
:
''
;
my
$mongoose_exe
=
'.'
.
$dir_separator
.
'mongoose'
.
$exe_ext
;
my
$embed_exe
=
'.'
.
$dir_separator
.
'embed'
.
$exe_ext
;
my
$unit_test_exe
=
'.'
.
$dir_separator
.
'unit_test'
.
$exe_ext
;
my
$exit_code
=
0
;
my
@files_to_delete
=
(
'debug.log'
,
'access.log'
,
$config
,
"$root/a/put.txt"
,
...
...
@@ -51,9 +52,9 @@ sub get_num_of_log_entries {
# Send the request to the 127.0.0.1:$port and return the reply
sub
req
{
my
(
$request
,
$inc
,
$timeout
)
=
@_
;
my
$sock
=
IO::Socket::
INET
->
new
(
Proto
=>
"tcp"
,
PeerAddr
=>
'127.0.0.1'
,
PeerPort
=>
$port
);
fail
(
"Cannot connect: $!"
)
unless
$sock
;
my
$sock
=
IO::Socket::
INET
->
new
(
Proto
=>
6
,
PeerAddr
=>
'127.0.0.1'
,
PeerPort
=>
$port
);
fail
(
"Cannot connect
to http://127.0.0.1:$port
: $!"
)
unless
$sock
;
$sock
->
autoflush
(
1
);
foreach
my
$byte
(
split
//
,
$request
)
{
last
unless
print
$sock
$byte
;
...
...
@@ -97,7 +98,6 @@ sub spawn {
if
(
on_windows
())
{
my
@args
=
split
/\s+/
,
$cmdline
;
my
$executable
=
$args
[
0
];
$executable
.=
'.exe'
;
Win32::
Spawn
(
$executable
,
$cmdline
,
$pid
);
die
"Cannot spawn @_: $!"
unless
$pid
;
}
else
{
...
...
@@ -155,13 +155,13 @@ if (scalar(@ARGV) > 0 and $ARGV[0] eq 'unit') {
# Command line options override config files settings
write_file
(
$config
,
"access_log_file access.log\n"
.
"listening_ports 127.0.0.1:12345\n"
);
spawn
(
"$exe -listening_ports 127.0.0.1:$port"
);
spawn
(
"$
mongoose_
exe -listening_ports 127.0.0.1:$port"
);
o
(
"GET /test/hello.txt HTTP/1.0\n\n"
,
'HTTP/1.1 200 OK'
,
'Loading config file'
);
unlink
$config
;
kill_spawned_child
();
# Spawn the server on port $port
my
$cmd
=
"$exe "
.
my
$cmd
=
"$
mongoose_
exe "
.
"-listening_ports 127.0.0.1:$port "
.
"-access_log_file access.log "
.
"-error_log_file debug.log "
.
...
...
@@ -352,6 +352,8 @@ unless (scalar(@ARGV) > 0 and $ARGV[0] eq "basic_tests") {
unlink
"$root/.htpasswd"
;
o
(
"GET /dir%20with%20spaces/hello.cgi HTTP/1.0\n\r\n"
,
'HTTP/1.1 200 OK.+hello'
,
'CGI script with spaces in path'
);
o
(
"GET /env.cgi HTTP/1.0\n\r\n"
,
'HTTP/1.1 200 OK'
,
'GET CGI file'
);
o
(
"GET /bad2.cgi HTTP/1.0\n\n"
,
"HTTP/1.1 123 Please pass me to the client\r"
,
'CGI Status code text'
);
...
...
@@ -410,9 +412,9 @@ unless (scalar(@ARGV) > 0 and $ARGV[0] eq "basic_tests") {
# Manipulate the passwords file
my
$path
=
'test_htpasswd'
;
unlink
$path
;
system
(
"$exe -A $path a b c"
)
==
0
system
(
"$
mongoose_
exe -A $path a b c"
)
==
0
or
fail
(
"Cannot add user in a passwd file"
);
system
(
"$exe -A $path a b c2"
)
==
0
system
(
"$
mongoose_
exe -A $path a b c2"
)
==
0
or
fail
(
"Cannot edit user in a passwd file"
);
my
$content
=
read_file
(
$path
);
$content
=~
/^b:a:\w+$/gs
or
fail
(
"Bad content of the passwd file"
);
...
...
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