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
2e65ce82
Commit
2e65ce82
authored
Apr 26, 2017
by
Deomid Ryabkov
Committed by
Cesanta Bot
Apr 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mg_parse_uri for URIs with fragment but no qs
PUBLISHED_FROM=8fb53581e8979c28026f9c2bcacb89de740c18cf
parent
a35e5bd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
mongoose.c
mongoose.c
+15
-10
No files found.
mongoose.c
View file @
2e65ce82
...
...
@@ -4839,17 +4839,20 @@ int mg_ssl_if_mbed_random(void *ctx, unsigned char *buf, size_t len) {
/* Amalgamated: #include "mongoose/src/uri.h" */
/*
* scan string until `sep`, keeping track of component boundaries in `res`.
* scan string until encountering one of `seps`, keeping track of component
* boundaries in `res`.
*
* `p` will point to the char after the separator or it will be `end`.
*/
static
void
parse_uri_component
(
const
char
**
p
,
const
char
*
end
,
char
sep
,
struct
mg_str
*
res
)
{
static
void
parse_uri_component
(
const
char
**
p
,
const
char
*
end
,
const
char
*
seps
,
struct
mg_str
*
res
)
{
const
char
*
q
;
res
->
p
=
*
p
;
for
(;
*
p
<
end
;
(
*
p
)
++
)
{
if
(
**
p
==
sep
)
{
break
;
for
(
q
=
seps
;
*
q
!=
'\0'
;
q
++
)
{
if
(
**
p
==
*
q
)
break
;
}
if
(
*
q
!=
'\0'
)
break
;
}
res
->
len
=
(
*
p
)
-
res
->
p
;
if
(
*
p
<
end
)
(
*
p
)
++
;
...
...
@@ -4964,9 +4967,11 @@ int mg_parse_uri(const struct mg_str uri, struct mg_str *scheme,
break
;
case
P_REST
:
/* `p` points to separator. `path` includes the separator */
parse_uri_component
(
&
p
,
end
,
'?'
,
&
rpath
);
parse_uri_component
(
&
p
,
end
,
'#'
,
&
rquery
);
parse_uri_component
(
&
p
,
end
,
'\0'
,
&
rfragment
);
parse_uri_component
(
&
p
,
end
,
"?#"
,
&
rpath
);
if
(
p
<
end
&&
*
(
p
-
1
)
==
'?'
)
{
parse_uri_component
(
&
p
,
end
,
"#"
,
&
rquery
);
}
parse_uri_component
(
&
p
,
end
,
""
,
&
rfragment
);
break
;
}
}
...
...
@@ -4997,7 +5002,7 @@ int mg_normalize_uri_path(const struct mg_str *in, struct mg_str *out) {
while
(
s
<
se
)
{
const
char
*
next
=
s
;
struct
mg_str
component
;
parse_uri_component
(
&
next
,
se
,
'/'
,
&
component
);
parse_uri_component
(
&
next
,
se
,
"/"
,
&
component
);
if
(
mg_vcmp
(
&
component
,
"."
)
==
0
)
{
/* Yum. */
}
else
if
(
mg_vcmp
(
&
component
,
".."
)
==
0
)
{
...
...
@@ -7282,7 +7287,7 @@ MG_INTERNAL int mg_uri_to_local_path(struct http_message *hm,
}
}
if
(
u
>=
cp_end
)
break
;
parse_uri_component
((
const
char
**
)
&
next
,
cp_end
,
'/'
,
&
component
);
parse_uri_component
((
const
char
**
)
&
next
,
cp_end
,
"/"
,
&
component
);
if
(
component
.
len
>
0
)
{
int
len
;
memmove
(
p
+
1
,
component
.
p
,
component
.
len
);
...
...
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