Skip to content

Commit

Permalink
Spec update: percent-encode ' in queries of special URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Jun 8, 2018
1 parent 754ff5f commit 1c50c08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spe

## Current status

whatwg-url is currently up to date with the URL spec up to commit [ac532ae](https://github.com/whatwg/url/commit/ac532aeaf418caaa996ed05636b752f2caf118e1).
whatwg-url is currently up to date with the URL spec up to commit [6ef17eb](https://github.com/whatwg/url/commit/6ef17ebe1220a7e7c0cfff0785017502ee18808b).

## API

Expand Down
6 changes: 3 additions & 3 deletions scripts/get-latest-platform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ process.on("unhandledRejection", err => {
// 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 = "88b75886e68ce5197019a2707fc6f1b9645a4639";
const commitHash = "9b7f4414f226443ec95f823a92d1c33c8e0c67bb";

// Have to use RawGit as JSDOM.fromURL checks Content-Type header.
const urlPrefix = `https://rawgit.com/w3c/web-platform-tests/${commitHash}/url/`;
const urlPrefix = `https://rawgit.com/web-platform-tests/wpt/${commitHash}/url/`;
const targetDir = path.resolve(__dirname, "..", "test", "web-platform-tests");

for (const file of ["urltestdata.json", "setters_tests.json", "toascii.json"]) {
request(`${urlPrefix}${file}`)
request(`${urlPrefix}resources/${file}`)
.pipe(fs.createWriteStream(path.resolve(targetDir, file)));
}

Expand Down
6 changes: 4 additions & 2 deletions src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,10 @@ URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) {

const buffer = Buffer.from(this.buffer); // TODO: Use encoding override instead
for (let i = 0; i < buffer.length; ++i) {
if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 ||
buffer[i] === 0x3C || buffer[i] === 0x3E) {
if (buffer[i] < 0x21 ||
buffer[i] > 0x7E ||
buffer[i] === 0x22 || buffer[i] === 0x23 || buffer[i] === 0x3C || buffer[i] === 0x3E ||
(buffer[i] === 0x27 && isSpecial(this.url))) {
this.url.query += percentEncode(buffer[i]);
} else {
this.url.query += String.fromCodePoint(buffer[i]);
Expand Down

0 comments on commit 1c50c08

Please sign in to comment.