Skip to content

Commit

Permalink
Spec update: disallow invalid IPv4 in the IPv6 parser
Browse files Browse the repository at this point in the history
This matches whatwg/url#196.
  • Loading branch information
domenic committed Jan 9, 2017
1 parent 2556e46 commit 0d20c56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion scripts/get-latest-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const request = require("request");
// 1. Go to https://github.com/w3c/web-platform-tests/tree/master/url
// 2. Press "y" on your keyboard to get a permalink
// 3. Copy the commit hash
const commitHash = "1e1e80441b8d6a60f836de4005dba25698ecfe4a";
const commitHash = "6e9508aab07d0c3e81e2ae60bac32290c02cd8f2";

const sourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/urltestdata.json`;
const setterSourceURL = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}/url/setters_tests.json`;
Expand Down
18 changes: 10 additions & 8 deletions src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,24 @@ function parseIPv6(input) {
}
}

if (dotsSeen < 3 && input[pointer] !== p(".")) {
return failure;
}
ip[piecePtr] = ip[piecePtr] * 0x100 + value;

if (dotsSeen === 1 || dotsSeen === 3) {
++piecePtr;
}

if (input[pointer] !== undefined) {
++pointer;
if (input[pointer] === undefined && dotsSeen !== 3) {
return failure;
}

if (dotsSeen === 3 && input[pointer] !== undefined) {
return failure;
if (input[pointer] === p(".")) {
++pointer;
++dotsSeen;

if (input[pointer] === undefined) {
return failure;
}
}
++dotsSeen;
}
}

Expand Down

0 comments on commit 0d20c56

Please sign in to comment.