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
9d3af98a
Commit
9d3af98a
authored
Feb 09, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove repeating backslashes only on Windows
parent
84a76fba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
a.txt
test/\/a.txt
+1
-0
test.pl
test/test.pl
+3
-2
unit_test.c
test/unit_test.c
+30
-1
No files found.
test/\/a.txt
0 → 100644
View file @
9d3af98a
blah
test/test.pl
View file @
9d3af98a
...
...
@@ -201,7 +201,7 @@ $num_requests++;
write_file
(
"$root/a+.txt"
,
''
);
o
(
"GET /a+.txt HTTP/1.0\n\n"
,
'HTTP/1.1 200 OK'
,
'URL-decoding, + in URI'
);
#o("GET /hh HTTP/1.0\n\n", 'HTTP/1.1 200 OK', 'GET admin URI
');
o
(
"GET /%5c/a.txt HTTP/1.0\n\n"
,
'blah'
,
'GET dir backslash
'
);
# Test HTTP version parsing
o
(
"GET / HTTPX/1.0\r\n\r\n"
,
'400 Bad Request'
,
'Bad HTTP Version'
,
0
);
...
...
@@ -213,7 +213,8 @@ o("GET / HTTP/02.0\r\n\r\n", '505 HTTP version not supported',
# File with leading single dot
o
(
"GET /.leading.dot.txt HTTP/1.0\n\n"
,
'abc123'
,
'Leading dot 1'
);
o
(
"GET /...leading.dot.txt HTTP/1.0\n\n"
,
'abc123'
,
'Leading dot 2'
);
o
(
"GET /../\\\\/.//...leading.dot.txt HTTP/1.0\n\n"
,
'abc123'
,
'Leading dot 3'
);
o
(
"GET /../\\\\/.//...leading.dot.txt HTTP/1.0\n\n"
,
'abc123'
,
'Leading dot 3'
)
if
on_windows
();
o
(
"GET .. HTTP/1.0\n\n"
,
'400 Bad Request'
,
'Leading dot 4'
,
0
);
mkdir
$test_dir
unless
-
d
$test_dir
;
...
...
test/unit_test.c
View file @
9d3af98a
#include "mongoose.c"
int
main
(
void
)
{
static
void
test_match_prefix
(
void
)
{
assert
(
match_prefix
(
"/a/"
,
3
,
"/a/b/c"
)
==
3
);
assert
(
match_prefix
(
"/a/"
,
3
,
"/ab/c"
)
==
-
1
);
assert
(
match_prefix
(
"/*/"
,
3
,
"/ab/c"
)
==
4
);
...
...
@@ -25,6 +25,35 @@ int main(void) {
assert
(
match_prefix
(
"**.a$|**.b$"
,
11
,
"/a/b.b/"
)
==
-
1
);
assert
(
match_prefix
(
"**.a$|**.b$"
,
11
,
"/a/b.b"
)
==
6
);
assert
(
match_prefix
(
"**.a$|**.b$"
,
11
,
"/a/b.a"
)
==
6
);
}
static
void
test_remove_double_dots
()
{
struct
{
char
before
[
20
],
after
[
20
];
}
data
[]
=
{
{
"////a"
,
"/a"
},
{
"/....."
,
"/."
},
{
"/......"
,
"/"
},
{
"..."
,
"..."
},
{
"/...///"
,
"/./"
},
{
"/a...///"
,
"/a.../"
},
{
"/.x"
,
"/.x"
},
#if defined(_WIN32)
{
"/
\\
"
,
"/"
},
#else
{
"/
\\
"
,
"/
\\
"
},
#endif
{
"/a
\\
"
,
"/a
\\
"
},
};
size_t
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
data
);
i
++
)
{
//printf("[%s] -> [%s]\n", data[i].before, data[i].after);
remove_double_dots_and_double_slashes
(
data
[
i
].
before
);
assert
(
strcmp
(
data
[
i
].
before
,
data
[
i
].
after
)
==
0
);
}
}
int
main
(
void
)
{
test_match_prefix
();
test_remove_double_dots
();
return
0
;
}
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