Skip to content

Commit

Permalink
src, url: clarify URL_FLAG_TERMINATED
Browse files Browse the repository at this point in the history
Do not call any completion callback with TERMINATED.
  • Loading branch information
TimothyGu committed Mar 30, 2017
1 parent 863aa02 commit 9e9dfe2
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ namespace url {
state = kNoScheme;
continue;
} else {
url->flags |= URL_FLAGS_TERMINATED;
url->flags |= URL_FLAGS_FAILED;
return;
}
break;
Expand All @@ -656,9 +656,12 @@ namespace url {
p++;
continue;
} else if (ch == ':' || (has_state_override && ch == kEOL)) {
buffer += ':';
if (buffer.size() > 0) {
buffer += ':';
url->scheme = buffer;
} else if (has_state_override) {
url->flags |= URL_FLAGS_TERMINATED;
return;
}
if (IsSpecial(url->scheme)) {
url->flags |= URL_FLAGS_SPECIAL;
Expand Down Expand Up @@ -692,7 +695,7 @@ namespace url {
p = input;
continue;
} else {
url->flags |= URL_FLAGS_TERMINATED;
url->flags |= URL_FLAGS_FAILED;
return;
}
break;
Expand Down Expand Up @@ -947,7 +950,6 @@ namespace url {
buffer.clear();
state = kPort;
if (state_override == kHostname) {
url->flags |= URL_FLAGS_TERMINATED;
return;
}
} else if (ch == kEOL ||
Expand All @@ -968,7 +970,6 @@ namespace url {
buffer.clear();
state = kPathStart;
if (has_state_override) {
url->flags |= URL_FLAGS_TERMINATED;
return;
}
} else {
Expand Down Expand Up @@ -1005,9 +1006,14 @@ namespace url {
}
url->port = NormalizePort(url->scheme, port);
buffer.clear();
}
if (has_state_override)
} else if (has_state_override) {
// TODO(TimothyGu): Similar case as above.
if (state_override == kHost)
url->port = -1;
else
url->flags |= URL_FLAGS_TERMINATED;
return;
}
state = kPathStart;
continue;
} else {
Expand Down Expand Up @@ -1275,7 +1281,9 @@ namespace url {
HarvestBase(env, &base, base_obj.As<Object>());

URL::Parse(input, len, state_override, &url, &base, has_base);
if (url.flags & URL_FLAGS_INVALID_PARSE_STATE)
if ((url.flags & URL_FLAGS_INVALID_PARSE_STATE) ||
((state_override != kUnknownState) &&
(url.flags & URL_FLAGS_TERMINATED)))
return;

// Define the return value placeholders
Expand Down

0 comments on commit 9e9dfe2

Please sign in to comment.