From 53582bd3ba6d26e633b8e801b6b8bd2e927095d8 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sat, 19 Mar 2022 09:58:49 -0400 Subject: [PATCH] fix: use `getUrlFromOP()` for `fixes` links When parsing `fixes` links, use the same code that is used for parsing the `refs` and `PR-URL` links. This avoids the manual URL construction that was inserting bad links into the metadata for the npm update pull requests. --- lib/links.js | 12 +++++------- test/fixtures/op_html.json | 4 +++- test/unit/links.test.js | 12 ++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/links.js b/lib/links.js index ad498b8aa..6a3e534fa 100644 --- a/lib/links.js +++ b/lib/links.js @@ -17,17 +17,15 @@ export class LinkParser { } getFixesUrlsFromArray(arr) { - const { owner, repo } = this; - const result = []; + const result = new Set(); for (const item of arr) { const m = item.match(FIX_RE); if (!m) continue; - const fix = m[3]; - const url = fix.replace(/^#/, - `${owner}/${repo}#`).replace('#', '/issues/'); - result.push(`https://github.com/${url}`); + const ref = m[3]; + const url = this.getUrlFromOP(ref); + if (url) result.add(url); } - return result; + return Array.from(result); } getRefsUrlsFromArray(arr) { diff --git a/test/fixtures/op_html.json b/test/fixtures/op_html.json index 3b6045657..693703e85 100644 --- a/test/fixtures/op_html.json +++ b/test/fixtures/op_html.json @@ -2,5 +2,7 @@ "

The npm install rules had a hidden dependency on the node binary
\ninstall rule creating the $PREFIX/bin directory.

\n

Because with ./configure --shared no binary is created, the rule
\nsubsequently failed. Fix that by creating the directory before
\ncreating the symlinks to the npm and npx scripts.

\n

(Whether it makes sense to install npm without a node binary is
\na separate question. This commit is not taking positions. :-))

\n

Regression introduced in commit ed8c89a (\"build: fix shared installing
\ntarget\") which, as the commit log indicates, was itself a bug fix for
\nthe ./configure --shared install.

\n

Fixes: #16437
\nRefs: #15148

", "

Refs: #16293

\n
Checklist
\n\n\n
Affected core subsystem(s)
\n\n

vm

", "

Included reference to \\'constant time\\' in crypto.timingSafeEqual description

\n

Fixes : #16504

", - "
Checklist
Affected core subsystem(s)

doc, dgram

Refs: https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124

" + "
Checklist
\n\n
Affected core subsystem(s)
\n

doc, dgram

\n

Refs: https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124

", + "

v8.5.5 (2022-03-17)

\n

Bug Fixes

\n\n

Documentation

\n\n

Dependencies

\n", + "

Original commit from v8 repo:

\n
[mac][wasm] Work around MacOS 11.2 code page decommit failures\n\nMacOS 11.2 refuses to set \"no access\" permissions on memory that\nwe previously used for JIT-compiled code. It is still unclear\nwhether this is WAI on the part of the kernel. In the meantime,\nas a workaround, we use madvise(..., MADV_FREE_REUSABLE) instead\nof mprotect(..., NONE) when discarding code pages. This is inspired\nby what Chromium's gin platform does.\n\nFixed: v8:11389\nChange-Id: I866586932573b4253002436ae5eee4e0411c45fc\nReviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2679688\nCommit-Queue: Jakob Kummerow <jkummerow@chromium.org>\nCommit-Queue: Michael Lippautz <mlippautz@chromium.org>\nAuto-Submit: Jakob Kummerow <jkummerow@chromium.org>\nReviewed-by: Michael Lippautz <mlippautz@chromium.org>\nCr-Commit-Position: refs/heads/master@{#72559}\n
\n

Fixes #37061
\nRef: https://bugs.chromium.org/p/v8/issues/detail?id=11389#c18

\n

For test:

\n\n
./node crash.js\n{\"exports\":[],\"reexports\":[]}
" ] diff --git a/test/unit/links.test.js b/test/unit/links.test.js index f95ddcd51..71d582af8 100644 --- a/test/unit/links.test.js +++ b/test/unit/links.test.js @@ -18,8 +18,20 @@ describe('LinkParser', () => { fixes: ['https://github.com/nodejs/node/issues/16504'], refs: [] }, { + // Parse non-GitHub refs. + // https://github.com/nodejs/node/pull/17107 fixes: [], refs: ['https://en.wikipedia.org/w/index.php?title=IPv6_address&type=revision&diff=809494791&oldid=804196124'] + }, { + // Parse npm update pull requests. + // https://github.com/nodejs/node/pull/42382 + fixes: [], + refs: [] + }, { + // Contains `Fixed: v8:11389` which should be ignored. + // https://github.com/nodejs/node/pull/37276 + fixes: [], + refs: ['https://bugs.chromium.org/p/v8/issues/detail?id=11389#c18'] }]; for (let i = 0; i < htmls.length; ++i) {