summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-03 17:44:43 +0900
committerDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-03 18:11:51 +0900
commitf8f46f99175e4ae5531983306930bd3685cb46d4 (patch)
tree7a98df52ca7b7c5a84f7cec00dd34ec4b5753b53 /src
parent33a19b46ca8ad9dd00f4a563a6960b5de11a3456 (diff)
downloadandroid-node-v8-f8f46f99175e4ae5531983306930bd3685cb46d4.tar.gz
android-node-v8-f8f46f99175e4ae5531983306930bd3685cb46d4.tar.bz2
android-node-v8-f8f46f99175e4ae5531983306930bd3685cb46d4.zip
url: change path parsing for non-special URLs
This changes to the way path parsing for non-special URLs. It allows paths to be empty for non-special URLs and also takes that into account when serializing. Fixes: https://github.com/nodejs/node/issues/11962 Refs: https://github.com/whatwg/url/pull/213 PR-URL: https://github.com/nodejs/node/pull/12058 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_url.cc28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index 54a2944588..f9965d537b 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -862,8 +862,10 @@ namespace url {
}
break;
case kRelativeSlash:
- if (ch == '/' || special_back_slash) {
+ if (IsSpecial(url->scheme) && (ch == '/' || ch == '\\')) {
state = kSpecialAuthorityIgnoreSlashes;
+ } else if (ch == '/') {
+ state = kAuthority;
} else {
if (base->flags & URL_FLAGS_HAS_USERNAME) {
url->flags |= URL_FLAGS_HAS_USERNAME;
@@ -1145,9 +1147,25 @@ namespace url {
}
break;
case kPathStart:
- state = kPath;
- if (ch != '/' && !special_back_slash)
- continue;
+ if (IsSpecial(url->scheme)) {
+ state = kPath;
+ if (ch != '/' && ch != '\\') {
+ continue;
+ }
+ } else if (!has_state_override && ch == '?') {
+ url->flags |= URL_FLAGS_HAS_QUERY;
+ url->query.clear();
+ state = kQuery;
+ } else if (!has_state_override && ch == '#') {
+ url->flags |= URL_FLAGS_HAS_FRAGMENT;
+ url->fragment.clear();
+ state = kFragment;
+ } else if (ch != kEOL) {
+ state = kPath;
+ if (ch != '/') {
+ continue;
+ }
+ }
break;
case kPath:
if (ch == kEOL ||
@@ -1165,7 +1183,7 @@ namespace url {
url->flags |= URL_FLAGS_HAS_PATH;
url->path.push_back("");
}
- } else {
+ } else if (!IsSingleDotSegment(buffer)) {
if (url->scheme == "file:" &&
url->path.empty() &&
buffer.size() == 2 &&