Skip to content

Commit 1415e8d

Browse files
committed
Report all hostname state failures
Follows whatwg/url@c23aec1. Does not impact normal URL parsing, but instead only direct usage of the underlying URL record API.
1 parent 5f6ab8a commit 1415e8d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/url-state-machine.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,9 @@ function URLStateMachine(input, base, encodingOverride, url, stateOverride) {
536536
this.state = stateOverride || "scheme start";
537537

538538
this.buffer = "";
539-
this.atFlag = false;
540-
this.arrFlag = false;
541-
this.passwordTokenSeenFlag = false;
539+
this.atSignSeen = false;
540+
this.insideBrackets = false;
541+
this.passwordTokenSeen = false;
542542

543543
this.input = Array.from(this.input, c => c.codePointAt(0));
544544

@@ -751,22 +751,22 @@ URLStateMachine.prototype["parse special authority ignore slashes"] = function p
751751
URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) {
752752
if (c === p("@")) {
753753
this.parseError = true;
754-
if (this.atFlag) {
754+
if (this.atSignSeen) {
755755
this.buffer = `%40${this.buffer}`;
756756
}
757-
this.atFlag = true;
757+
this.atSignSeen = true;
758758

759759
// careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars
760760
const len = countSymbols(this.buffer);
761761
for (let pointer = 0; pointer < len; ++pointer) {
762762
const codePoint = this.buffer.codePointAt(pointer);
763763

764-
if (codePoint === p(":") && !this.passwordTokenSeenFlag) {
765-
this.passwordTokenSeenFlag = true;
764+
if (codePoint === p(":") && !this.passwordTokenSeen) {
765+
this.passwordTokenSeen = true;
766766
continue;
767767
}
768768
const encodedCodePoints = utf8PercentEncodeCodePoint(codePoint, isUserinfoPercentEncode);
769-
if (this.passwordTokenSeenFlag) {
769+
if (this.passwordTokenSeen) {
770770
this.url.password += encodedCodePoints;
771771
} else {
772772
this.url.username += encodedCodePoints;
@@ -775,7 +775,7 @@ URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr)
775775
this.buffer = "";
776776
} else if (isNaN(c) || c === p("/") || c === p("?") || c === p("#") ||
777777
(isSpecial(this.url) && c === p("\\"))) {
778-
if (this.atFlag && this.buffer === "") {
778+
if (this.atSignSeen && this.buffer === "") {
779779
this.parseError = true;
780780
return failure;
781781
}
@@ -794,14 +794,14 @@ URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
794794
if (this.stateOverride && this.url.scheme === "file") {
795795
--this.pointer;
796796
this.state = "file host";
797-
} else if (c === p(":") && !this.arrFlag) {
797+
} else if (c === p(":") && !this.insideBrackets) {
798798
if (this.buffer === "") {
799799
this.parseError = true;
800800
return failure;
801801
}
802802

803803
if (this.stateOverride === "hostname") {
804-
return false;
804+
return failure;
805805
}
806806

807807
const host = parseHost(this.buffer, isNotSpecial(this.url));
@@ -821,7 +821,7 @@ URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
821821
} else if (this.stateOverride && this.buffer === "" &&
822822
(includesCredentials(this.url) || this.url.port !== null)) {
823823
this.parseError = true;
824-
return false;
824+
return failure;
825825
}
826826

827827
const host = parseHost(this.buffer, isNotSpecial(this.url));
@@ -837,9 +837,9 @@ URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) {
837837
}
838838
} else {
839839
if (c === p("[")) {
840-
this.arrFlag = true;
840+
this.insideBrackets = true;
841841
} else if (c === p("]")) {
842-
this.arrFlag = false;
842+
this.insideBrackets = false;
843843
}
844844
this.buffer += cStr;
845845
}

0 commit comments

Comments
 (0)