mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 15:01:03 +08:00
Fix #1626 - ignore @ in query string
This commit is contained in:
parent
9876e3afd7
commit
f40b272eeb
@ -5307,19 +5307,19 @@ static struct url urlparse(const char *url) {
|
||||
struct url u;
|
||||
memset(&u, 0, sizeof(u));
|
||||
for (i = 0; url[i] != '\0'; i++) {
|
||||
if (i > 0 && u.host == 0 && url[i - 1] == '/' && url[i] == '/') {
|
||||
if (url[i] == '/' && i > 0 && u.host == 0 && url[i - 1] == '/') {
|
||||
u.host = i + 1;
|
||||
u.port = 0;
|
||||
} else if (url[i] == ']') {
|
||||
u.port = 0; // IPv6 URLs, like http://[::1]/bar
|
||||
} else if (url[i] == ':' && u.port == 0 && u.uri == 0) {
|
||||
u.port = i + 1;
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0) {
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0 && u.uri == 0) {
|
||||
u.user = u.host;
|
||||
u.pass = u.port;
|
||||
u.host = i + 1;
|
||||
u.port = 0;
|
||||
} else if (u.host && u.uri == 0 && url[i] == '/') {
|
||||
} else if (url[i] == '/' && u.host && u.uri == 0) {
|
||||
u.uri = i;
|
||||
}
|
||||
}
|
||||
|
@ -15,19 +15,19 @@ static struct url urlparse(const char *url) {
|
||||
struct url u;
|
||||
memset(&u, 0, sizeof(u));
|
||||
for (i = 0; url[i] != '\0'; i++) {
|
||||
if (i > 0 && u.host == 0 && url[i - 1] == '/' && url[i] == '/') {
|
||||
if (url[i] == '/' && i > 0 && u.host == 0 && url[i - 1] == '/') {
|
||||
u.host = i + 1;
|
||||
u.port = 0;
|
||||
} else if (url[i] == ']') {
|
||||
u.port = 0; // IPv6 URLs, like http://[::1]/bar
|
||||
} else if (url[i] == ':' && u.port == 0 && u.uri == 0) {
|
||||
u.port = i + 1;
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0) {
|
||||
} else if (url[i] == '@' && u.user == 0 && u.pass == 0 && u.uri == 0) {
|
||||
u.user = u.host;
|
||||
u.pass = u.port;
|
||||
u.host = i + 1;
|
||||
u.port = 0;
|
||||
} else if (u.host && u.uri == 0 && url[i] == '/') {
|
||||
} else if (url[i] == '/' && u.host && u.uri == 0) {
|
||||
u.uri = i;
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +219,8 @@ static void test_url(void) {
|
||||
ASSERT(vcmp(mg_url_user("p://u:p@foo"), "u"));
|
||||
ASSERT(vcmp(mg_url_pass("p://u:p@foo"), "p"));
|
||||
ASSERT(vcmp(mg_url_pass("p://u:p@foo//a@b"), "p"));
|
||||
ASSERT(vcmp(mg_url_user("p://foo/q?mail=a@b.c"), ""));
|
||||
ASSERT(vcmp(mg_url_pass("p://foo/q?mail=a@b.c"), ""));
|
||||
|
||||
// URI
|
||||
ASSERT(strcmp(mg_url_uri("p://foo"), "/") == 0);
|
||||
@ -228,6 +230,7 @@ static void test_url(void) {
|
||||
ASSERT(strcmp(mg_url_uri("p://foo:12/a/b/c"), "/a/b/c") == 0);
|
||||
ASSERT(strcmp(mg_url_uri("p://[::1]:12/a/b/c"), "/a/b/c") == 0);
|
||||
ASSERT(strcmp(mg_url_uri("p://[ab::1]:12/a/b/c"), "/a/b/c") == 0);
|
||||
ASSERT(strcmp(mg_url_uri("p://foo/q?mail=a@b.c"), "/q?mail=a@b.c") == 0);
|
||||
}
|
||||
|
||||
static void test_base64(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user