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
5224afb9
Commit
5224afb9
authored
Mar 17, 2015
by
Marko Mikulicic
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #485 from dsrosario/fix_remove_double_dots
parents
c52e0744
3bd79c7c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
mongoose.c
mongoose.c
+3
-1
unit_test.c
test/unit_test.c
+7
-5
No files found.
mongoose.c
View file @
5224afb9
...
...
@@ -2430,7 +2430,9 @@ static void remove_double_dots_and_double_slashes(char *s) {
// Skip all following slashes, backslashes and double-dots
while
(
s
[
0
]
!=
'\0'
)
{
if
(
s
[
0
]
==
'/'
||
s
[
0
]
==
'\\'
)
{
s
++
;
}
else
if
(
s
[
0
]
==
'.'
&&
s
[
1
]
==
'.'
)
{
s
+=
2
;
}
else
if
(
s
[
0
]
==
'.'
&&
(
s
[
1
]
==
'/'
||
s
[
1
]
==
'\\'
))
{
s
+=
2
;
}
else
if
(
s
[
0
]
==
'.'
&&
s
[
1
]
==
'.'
&&
s
[
2
]
==
'\0'
)
{
s
+=
2
;
}
else
if
(
s
[
0
]
==
'.'
&&
s
[
1
]
==
'.'
&&
(
s
[
2
]
==
'/'
||
s
[
2
]
==
'\\'
))
{
s
+=
3
;
}
else
{
break
;
}
}
}
...
...
test/unit_test.c
View file @
5224afb9
...
...
@@ -198,17 +198,19 @@ static const char *test_match_prefix(void) {
}
static
const
char
*
test_remove_double_dots
()
{
struct
{
char
before
[
20
],
after
[
2
0
];
}
data
[]
=
{
struct
{
char
before
[
30
],
after
[
3
0
];
}
data
[]
=
{
{
"////a"
,
"/a"
},
{
"/....."
,
"/."
},
{
"/......"
,
"/"
},
{
"/....."
,
"/.
....
"
},
{
"/......"
,
"/
......
"
},
{
"..."
,
"..."
},
{
"/...///"
,
"/./"
},
{
"/...///"
,
"/.
..
/"
},
{
"/a...///"
,
"/a.../"
},
{
"/.x"
,
"/.x"
},
{
"/
\\
"
,
"/"
},
{
"/a
\\
"
,
"/a
\\
"
},
{
"/a
\\\\
..."
,
"/a
\\
."
},
{
"/a
\\\\
..."
,
"/a
\\
..."
},
{
"foo/x..y/././y/../../.."
,
"foo/x..y/y/"
},
{
"foo/..x"
,
"foo/..x"
},
};
size_t
i
;
...
...
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