markdown-parity-check 0.2.39 → 0.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/compare.js +4 -2
- package/dist/src/markdown.js +8 -2
- package/dist/src/normalize.d.ts +30 -2
- package/dist/src/normalize.js +143 -3
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,10 +78,10 @@ A value that is outside these ranges, or that is not a plain run of digits, stop
|
|
|
78
78
|
|
|
79
79
|
### Example output
|
|
80
80
|
|
|
81
|
-
This is the text report for the matching fixture pair in this repository, run with version 0.2.
|
|
81
|
+
This is the text report for the matching fixture pair in this repository, run with version 0.2.40 on 2026-11-15. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
|
|
82
82
|
|
|
83
83
|
```text
|
|
84
|
-
markdown-parity-check 0.2.
|
|
84
|
+
markdown-parity-check 0.2.40 (offline mode)
|
|
85
85
|
Result: PASS (0 error(s), 0 warning(s), 1 info)
|
|
86
86
|
|
|
87
87
|
HTML: test/fixtures/same/page.html (file, 1,017 bytes, base https://example.com/page)
|
|
@@ -151,7 +151,7 @@ The choice follows the type of the response, not the request. Any other response
|
|
|
151
151
|
|
|
152
152
|
JavaScript is not executed. Content that a page builds in the browser is compared as the server sent it. Block matching is heuristic, so some layouts need an explicit selector. Reports mask URL query values and fragments and remove the user name and password of an address with a scheme, such as `https://user:password@host/`. Excerpts may still contain private page content. Review a report before you share it.
|
|
153
153
|
|
|
154
|
-
The masking is a display safeguard that does not hide ordinary text, so it has limits, and this paragraph is the full list. It removes the user name and password even when a tab, a line break or a space sits inside the user information, provided that the user information holds a colon, as in `user:password`. A user name alone, with no colon, is masked when a tab, a vertical tab or a form feed sits inside it, and is shown when a space, a no-break space, a line feed or a carriage return does, because a line break or a space between an address and an e-mail address is ordinary text. On a bare host name without a scheme, a query or a fragment is masked only when it holds an equals sign, so an anchor such as `example.com/docs/guide#step-3` and a path segment are shown. Not masked: a bracketed IPv6 host, a host with a trailing dot, a name with no dot other than `localhost
|
|
154
|
+
The masking is a display safeguard that does not hide ordinary text, so it has limits, and this paragraph is the full list. It removes the user name and password even when a tab, a line break or a space sits inside the user information, provided that the user information holds a colon, as in `user:password`. A user name alone, with no colon, is masked when a tab, a vertical tab or a form feed sits inside it, and is shown when a space, a no-break space, a line feed or a carriage return does, because a line break or a space between an address and an e-mail address is ordinary text. On a bare host name without a scheme, a query or a fragment is masked only when it holds an equals sign, so an anchor such as `example.com/docs/guide#step-3` and a path segment are shown. Not masked: a bracketed IPv6 host, a host with a trailing dot, a name with no dot other than `localhost` and an scp-style `git@host:path`. A scheme-less `user:password@host.example/path` is masked as `user:***@host.example/path`, and so is the e-mail link that the Markdown parser reads out of it, when a path, a query that holds a value or a fragment that holds an equals sign follows the host name. Without one, as in `user:password@host.example` or `Contact:jane@example.com`, it is shown, because text alone cannot tell a user name from a label. The scheme-less form is also shown when its host name holds a letter outside ASCII, or when its colon or at sign is written as a character reference or a fullwidth character. An address after `mailto:`, `xmpp:`, `sip:`, `sips:`, `acct:` or `im:` is shown as written. A plain space or a no-break space right after the colon of the user information, and a password of digits only that is followed by white space, are read as text and shown. The masking changes what a report shows and never what is compared, and a number difference inside a masked part still gives the number finding, with the values left out. In both formats U+200E, U+200F, U+061C, U+2028, U+2029 and the tag characters are removed from report text. The text report shows a line feed or a carriage return inside a string from a page or an argument as `\n` or `\r`.
|
|
155
155
|
|
|
156
156
|
A link target longer than 8192 characters stops the run with exit code 2 and an error that names the limit and does not repeat the target. The comparison handles a target once for every link, block or reference that touches it, so the time grew with the length of the target times that count. The limit applies to the target as the page or the Markdown wrote it, before any resolution.
|
|
157
157
|
|
|
@@ -272,12 +272,12 @@ Only after that check does it create the GitHub release with the verified tarbal
|
|
|
272
272
|
GitHub Actions publishes every version from 0.1.2 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
|
|
273
273
|
|
|
274
274
|
```sh
|
|
275
|
-
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.
|
|
275
|
+
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.40 --ignore-scripts && npm audit signatures
|
|
276
276
|
```
|
|
277
277
|
|
|
278
278
|
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance.
|
|
279
279
|
|
|
280
|
-
Tag `v0.2.
|
|
280
|
+
Tag `v0.2.40` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.40 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
|
|
281
281
|
|
|
282
282
|
## Security
|
|
283
283
|
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type FetchOptions, type FetchResult } from './fetch.js';
|
|
3
|
-
export declare const HELP = "markdown-parity-check 0.2.
|
|
3
|
+
export declare const HELP = "markdown-parity-check 0.2.40\nCompares the main content of a web page's HTML and Markdown representations and reports concrete\nmissing, added and changed blocks.\n\nUsage:\n markdown-parity-check --url <https://example.com/page> [--markdown-url <url>] [options]\n markdown-parity-check --html-file <page.html> --markdown-file <page.md> [--base-url <url>] [options]\n\nModes:\n --url <url> Fetch <url> twice: with Accept: text/html and with Accept: text/markdown.\n --markdown-url <url> Fetch the Markdown from this explicit address instead (requires --url).\n --html-file <path> Offline: local HTML file (requires --markdown-file).\n --markdown-file <path> Offline: local Markdown file (requires --html-file).\n --base-url <url> Offline: base for resolving relative links on both sides.\n\nOptions:\n --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\n --selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).\n --front-matter keep|strip\n Markdown front matter. keep (default) removes nothing and warns when the document\n starts with a YAML-looking fenced block; strip removes that leading block.\n --format text|json Report format (default: text).\n --output <path> Write the report to a file instead of stdout. Refuses to overwrite an input file.\n --timeout-ms <n> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\n --max-bytes <n> Cap on decoded response bytes per fetch (default: 5242880).\n --strict Treat warnings as rejecting findings too.\n --help, -h Show this help.\n --version, -V Show the version.\n\nExit codes:\n 0 comparison completed, no rejecting finding\n 1 comparison completed, rejecting content or delivery differences found\n 2 input, fetch, parse or report error prevented a reliable comparison\n\nOnly http(s) URLs to public addresses are fetched; loopback, private, link-local and other non-public\naddresses are refused, also behind DNS and redirects. No JavaScript is executed. Exit 0 does not prove\nsemantic equivalence.\n";
|
|
4
4
|
export declare class CliError extends Error {
|
|
5
5
|
}
|
|
6
6
|
export interface CliArgs {
|
package/dist/src/compare.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The comparison core: aligns blocks and turns the alignment into findings. Pure and network-free.
|
|
2
2
|
import { align, resolveLimits, AlignmentLimitError, UNCERTAIN_THRESHOLD } from './align.js';
|
|
3
|
-
import { codeWhitespaceKey, excerpt, hrefDifference, looseNormalize, maskHref, redactText, relativeHrefRelation, textKey, trimHref, visibleNumbers } from './normalize.js';
|
|
3
|
+
import { codeWhitespaceKey, excerpt, hrefDifference, looseNormalize, maskBareUserinfo, maskHref, redactText, relativeHrefRelation, textKey, trimHref, visibleNumbers } from './normalize.js';
|
|
4
4
|
// The excerpt masks the whole block text before it cuts it, so it is computed once per block. Up to 0.2.11 every
|
|
5
5
|
// finding computed it again, and a block with thousands of link findings did that thousands of times (0.2.12).
|
|
6
6
|
const sides = new WeakMap();
|
|
@@ -60,7 +60,9 @@ export function diffNumbers(a, b) {
|
|
|
60
60
|
}
|
|
61
61
|
// What a finding shows of a link. A link GFM made out of a hidden part of a URL shows neither text nor target.
|
|
62
62
|
const linkText = (l, other) => (l.masked || other?.masked ? '***' : redactText(l.shown ?? l.text));
|
|
63
|
-
|
|
63
|
+
// maskBareUserinfo runs before maskHref as well as after it: maskHref drops the fragment, and a target such as
|
|
64
|
+
// `user:secret@host.example#a=b` has no other delimiter, so after maskHref the shape would no longer be recognised.
|
|
65
|
+
const linkHref = (l, href) => (l.masked ? '***' : maskBareUserinfo(maskHref(maskBareUserinfo(href))));
|
|
64
66
|
/**
|
|
65
67
|
* Pairs the HTML block's links with the Markdown block's, in three steps.
|
|
66
68
|
*
|
package/dist/src/markdown.js
CHANGED
|
@@ -5,7 +5,7 @@ import { gfmFromMarkdown } from 'mdast-util-gfm';
|
|
|
5
5
|
import { BLOCK_TAGS, extractHtml, HtmlDepthError, MAX_NESTING_DEPTH, opensExcludedSubtree } from './html.js';
|
|
6
6
|
import { parseDocument, Parser } from 'htmlparser2';
|
|
7
7
|
import { Element, Text } from 'domhandler';
|
|
8
|
-
import { excerpt, extractNumbers, insideHiddenUrlPart, insideUserinfoSpan, LinkTargetError, looseNormalize, MAX_LINK_TARGET_CHARS, normalizeCode, resolveHref, shownField, shownNormalize, strictNormalize, userinfoSpansOf } from './normalize.js';
|
|
8
|
+
import { bareUserinfoSpansOf, excerpt, extractNumbers, insideHiddenUrlPart, insideUserinfoSpan, LinkTargetError, looseNormalize, MAX_LINK_TARGET_CHARS, normalizeCode, resolveHref, shownField, shownNormalize, strictNormalize, userinfoSpansOf } from './normalize.js';
|
|
9
9
|
export class MarkdownExtractError extends Error {
|
|
10
10
|
}
|
|
11
11
|
/** Deepest node nesting of a Markdown tree, counted with an explicit stack. */
|
|
@@ -226,7 +226,8 @@ function inline(ctx, node, run) {
|
|
|
226
226
|
// A GFM literal autolink starts with neither [ nor <. One that GFM found inside a hidden part of another URL
|
|
227
227
|
// is compared as usual but shown masked (0.2.12). So is one that starts inside the user information of an
|
|
228
228
|
// address, scheme included, which GFM cuts at white space: the head of "https://user:pa ss@host/" is a link of
|
|
229
|
-
// its own, and so is the tail "ss@host" read as an e-mail address.
|
|
229
|
+
// its own, and so is the tail "ss@host" read as an e-mail address. The same holds for the "secret@host.example"
|
|
230
|
+
// that GFM reads out of user:secret@host.example/path, which has no scheme separator (0.2.40).
|
|
230
231
|
const at = node.position?.start.offset;
|
|
231
232
|
if (at !== undefined && ctx.source[at] !== '[' && ctx.source[at] !== '<') {
|
|
232
233
|
if (insideHiddenUrlPart(ctx.source, at))
|
|
@@ -236,6 +237,11 @@ function inline(ctx, node, run) {
|
|
|
236
237
|
if (insideUserinfoSpan(ctx.userinfo, at))
|
|
237
238
|
link.masked = true;
|
|
238
239
|
}
|
|
240
|
+
if (!link.masked && ctx.source.includes('@')) {
|
|
241
|
+
ctx.bareUserinfo ??= bareUserinfoSpansOf(ctx.source);
|
|
242
|
+
if (insideUserinfoSpan(ctx.bareUserinfo, at))
|
|
243
|
+
link.masked = true;
|
|
244
|
+
}
|
|
239
245
|
}
|
|
240
246
|
run.links.push(link);
|
|
241
247
|
run.links.push(...inner.links);
|
package/dist/src/normalize.d.ts
CHANGED
|
@@ -108,10 +108,38 @@ export declare function dropAuthorityControls(text: string): string;
|
|
|
108
108
|
export declare function userinfoSpansOf(text: string): UserinfoSpan[];
|
|
109
109
|
/** Whether position at lies in a user information of spans, scheme included, the "@" included. */
|
|
110
110
|
export declare function insideUserinfoSpan(spans: UserinfoSpan[], at: number): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The credential-shaped "label:name@host" of a text that has no scheme separator, as in user:secret@host.example/p
|
|
113
|
+
* (0.2.40, found by an independent check of 0.2.39). The URL parser reads "user:" as a scheme and the rest as an opaque
|
|
114
|
+
* path, so maskHref found no user information, and GFM read "secret@host.example" as an e-mail address, so the
|
|
115
|
+
* secret reached a report as an excerpt and as the text and the target of a link. A span is found in a run (RUN) when
|
|
116
|
+
* a label, the letters, digits and the characters + . - that start with a letter and follow no scheme character,
|
|
117
|
+
* is followed by a colon and then by text that holds an "@" before the first slash, backslash, question mark or number
|
|
118
|
+
* sign, and that delimiter, which must be there, makes the address a URL-like one: a slash or a backslash, a query that
|
|
119
|
+
* starts with a name and an equals sign, or a number sign with an equals sign later in the run. The text after the
|
|
120
|
+
* last "@" up to the delimiter must be a host name (isBareHostText). The user information is the text between the
|
|
121
|
+
* colon and that "@", and it must not be empty.
|
|
122
|
+
*
|
|
123
|
+
* Not a span, so shown as written: a special scheme (https:user@host/ is masked by the other rules), a scheme of
|
|
124
|
+
* ADDRESS_SCHEMES, a label that follows a slash (the authority rules read //name:secret@host/), an address that
|
|
125
|
+
* no delimiter follows, as in "Contact:jane@example.com", and a question mark or a number sign that is not followed by
|
|
126
|
+
* a value, as in "Did you mean To:jane@example.com?". "label:jane@example.com" with no space is therefore shown
|
|
127
|
+
* unless a path, a query value or a fragment value follows, because text alone cannot tell a label from a user name.
|
|
128
|
+
* A failed candidate is scanned to its own delimiter and a found one to its "@", so the scan stays linear. The result
|
|
129
|
+
* is a display aid and is never part of a comparison key.
|
|
130
|
+
*/
|
|
131
|
+
export declare function findBareUserinfoSpans(text: string): UserinfoSpan[];
|
|
132
|
+
/** Masks the user information of every "label:name@host/path" that findBareUserinfoSpans finds, and leaves the label,
|
|
133
|
+
* the host and the rest as they are: user:secret@host.example/p?x=1 reads user:***@host.example/p?x=1. Display only. */
|
|
134
|
+
export declare function maskBareUserinfo(text: string): string;
|
|
135
|
+
/** The spans of findBareUserinfoSpans for a source text, with the characters that stripControlChars removes read as
|
|
136
|
+
* a letter, which keeps every position and does not end a run or a label. */
|
|
137
|
+
export declare function bareUserinfoSpansOf(text: string): UserinfoSpan[];
|
|
111
138
|
/** Masks user information, query values and fragments of every URL-like run in a piece of report text.
|
|
112
139
|
* maskParenUserinfo and maskAuthorityUserinfo run first, for the shapes the runs of RUN cannot see as one URL, and
|
|
113
|
-
*
|
|
114
|
-
* --format text report (0.2.16, found by an
|
|
140
|
+
* maskBareUserinfo for the name:secret@host shape without a scheme separator. stripControlChars runs last so a raw
|
|
141
|
+
* ANSI escape from a compared page or an argument cannot reach a plain --format text report (0.2.16, found by an
|
|
142
|
+
* outside review 2026-09-28). */
|
|
115
143
|
export declare function redactText(text: string): string;
|
|
116
144
|
/**
|
|
117
145
|
* The text with the parts that maskHref hides taken out of every URL-like run: user information, query values
|
package/dist/src/normalize.js
CHANGED
|
@@ -804,15 +804,155 @@ export function insideUserinfoSpan(spans, at) {
|
|
|
804
804
|
}
|
|
805
805
|
return false;
|
|
806
806
|
}
|
|
807
|
+
// Schemes whose address part is an e-mail address or a user at a host by design. "mailto:jane@example.com/x" and the
|
|
808
|
+
// like are shown as written, so the masking of a name and a secret before an "@" does not reach them.
|
|
809
|
+
const ADDRESS_SCHEMES = new Set(['mailto', 'xmpp', 'sip', 'sips', 'acct', 'im']);
|
|
810
|
+
/** Whether t[from, to) is a host name followed by an optional port, by the rule bareHostStart uses: dotted labels that
|
|
811
|
+
* end in a letters-only label of two or more characters or in an xn-- label, a dotted IPv4 address or localhost. A
|
|
812
|
+
* trailing dot, an empty label and a name with no dot other than localhost are not hosts. */
|
|
813
|
+
function isBareHostText(t, from, to) {
|
|
814
|
+
let end = to;
|
|
815
|
+
let k = to;
|
|
816
|
+
while (k > from && isDigit(t.charCodeAt(k - 1)))
|
|
817
|
+
k--;
|
|
818
|
+
if (k < to && k > from + 1 && t.charCodeAt(k - 1) === 0x3a)
|
|
819
|
+
end = k - 1;
|
|
820
|
+
if (end <= from)
|
|
821
|
+
return false;
|
|
822
|
+
let labels = 1;
|
|
823
|
+
let lastStart = from;
|
|
824
|
+
for (let i = from; i < end; i++) {
|
|
825
|
+
const c = t.charCodeAt(i);
|
|
826
|
+
if (c === 0x2e) {
|
|
827
|
+
if (i === lastStart || i + 1 >= end)
|
|
828
|
+
return false;
|
|
829
|
+
labels++;
|
|
830
|
+
lastStart = i + 1;
|
|
831
|
+
}
|
|
832
|
+
else if (!(isLetter(c) || isDigit(c) || c === 0x2d || c === 0x5f))
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
const name = t.slice(from, end);
|
|
836
|
+
if (labels === 1)
|
|
837
|
+
return name.replace(/\u017f/g, 's').toLowerCase() === 'localhost';
|
|
838
|
+
const last = t.slice(lastStart, end);
|
|
839
|
+
if (last.length >= 2 && /^[A-Za-z\u017f\u212a]+$/u.test(last))
|
|
840
|
+
return true;
|
|
841
|
+
if (last.length >= 5 && /^xn--[^_]*$/i.test(last))
|
|
842
|
+
return true;
|
|
843
|
+
return labels === 4 && /^\d{1,3}(?:\.\d{1,3}){3}$/.test(name);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* The credential-shaped "label:name@host" of a text that has no scheme separator, as in user:secret@host.example/p
|
|
847
|
+
* (0.2.40, found by an independent check of 0.2.39). The URL parser reads "user:" as a scheme and the rest as an opaque
|
|
848
|
+
* path, so maskHref found no user information, and GFM read "secret@host.example" as an e-mail address, so the
|
|
849
|
+
* secret reached a report as an excerpt and as the text and the target of a link. A span is found in a run (RUN) when
|
|
850
|
+
* a label, the letters, digits and the characters + . - that start with a letter and follow no scheme character,
|
|
851
|
+
* is followed by a colon and then by text that holds an "@" before the first slash, backslash, question mark or number
|
|
852
|
+
* sign, and that delimiter, which must be there, makes the address a URL-like one: a slash or a backslash, a query that
|
|
853
|
+
* starts with a name and an equals sign, or a number sign with an equals sign later in the run. The text after the
|
|
854
|
+
* last "@" up to the delimiter must be a host name (isBareHostText). The user information is the text between the
|
|
855
|
+
* colon and that "@", and it must not be empty.
|
|
856
|
+
*
|
|
857
|
+
* Not a span, so shown as written: a special scheme (https:user@host/ is masked by the other rules), a scheme of
|
|
858
|
+
* ADDRESS_SCHEMES, a label that follows a slash (the authority rules read //name:secret@host/), an address that
|
|
859
|
+
* no delimiter follows, as in "Contact:jane@example.com", and a question mark or a number sign that is not followed by
|
|
860
|
+
* a value, as in "Did you mean To:jane@example.com?". "label:jane@example.com" with no space is therefore shown
|
|
861
|
+
* unless a path, a query value or a fragment value follows, because text alone cannot tell a label from a user name.
|
|
862
|
+
* A failed candidate is scanned to its own delimiter and a found one to its "@", so the scan stays linear. The result
|
|
863
|
+
* is a display aid and is never part of a comparison key.
|
|
864
|
+
*/
|
|
865
|
+
export function findBareUserinfoSpans(text) {
|
|
866
|
+
const spans = [];
|
|
867
|
+
const runs = new RegExp(RUN.source, RUN.flags);
|
|
868
|
+
for (let run = runs.exec(text); run !== null; run = runs.exec(text)) {
|
|
869
|
+
const s = run.index;
|
|
870
|
+
const e = s + run[0].length;
|
|
871
|
+
if (!run[0].includes('@'))
|
|
872
|
+
continue;
|
|
873
|
+
let lastEquals = e - 1;
|
|
874
|
+
while (lastEquals >= s && text.charCodeAt(lastEquals) !== 0x3d)
|
|
875
|
+
lastEquals--;
|
|
876
|
+
let i = s;
|
|
877
|
+
while (i < e) {
|
|
878
|
+
if (!isLetter(text.charCodeAt(i)) || (i > s && isSchemeChar(text.charCodeAt(i - 1)))) {
|
|
879
|
+
i++;
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
let b = i;
|
|
883
|
+
while (b < e && isSchemeChar(text.charCodeAt(b)))
|
|
884
|
+
b++;
|
|
885
|
+
if (b + 1 >= e || text.charCodeAt(b) !== 0x3a) {
|
|
886
|
+
i = b;
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
let k = b + 1;
|
|
890
|
+
let lastAt = -1;
|
|
891
|
+
while (k < e) {
|
|
892
|
+
const c = text.charCodeAt(k);
|
|
893
|
+
if (c === 0x2f || c === 0x5c || c === 0x3f || c === 0x23)
|
|
894
|
+
break;
|
|
895
|
+
if (c === 0x40)
|
|
896
|
+
lastAt = k;
|
|
897
|
+
k++;
|
|
898
|
+
}
|
|
899
|
+
let ok = k < e && lastAt > b + 1 && isBareHostText(text, lastAt + 1, k);
|
|
900
|
+
if (ok) {
|
|
901
|
+
const d = text.charCodeAt(k);
|
|
902
|
+
if (d === 0x3f) {
|
|
903
|
+
let q = k + 1;
|
|
904
|
+
while (q < e && isParamChar(text.charCodeAt(q)))
|
|
905
|
+
q++;
|
|
906
|
+
ok = q > k + 1 && q < e && text.charCodeAt(q) === 0x3d;
|
|
907
|
+
}
|
|
908
|
+
else if (d === 0x23)
|
|
909
|
+
ok = lastEquals > k;
|
|
910
|
+
}
|
|
911
|
+
if (ok) {
|
|
912
|
+
const prev = i > s ? text.charCodeAt(i - 1) : -1;
|
|
913
|
+
ok = prev !== 0x2f && prev !== 0x5c && specialSchemeLength(text, i, e) !== b - i && !ADDRESS_SCHEMES.has(text.slice(i, b).toLowerCase());
|
|
914
|
+
}
|
|
915
|
+
if (ok) {
|
|
916
|
+
spans.push({ start: i, from: b + 1, at: lastAt });
|
|
917
|
+
i = lastAt + 1;
|
|
918
|
+
}
|
|
919
|
+
else
|
|
920
|
+
i = k;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return spans;
|
|
924
|
+
}
|
|
925
|
+
/** Masks the user information of every "label:name@host/path" that findBareUserinfoSpans finds, and leaves the label,
|
|
926
|
+
* the host and the rest as they are: user:secret@host.example/p?x=1 reads user:***@host.example/p?x=1. Display only. */
|
|
927
|
+
export function maskBareUserinfo(text) {
|
|
928
|
+
if (!text.includes('@'))
|
|
929
|
+
return text;
|
|
930
|
+
const spans = findBareUserinfoSpans(text);
|
|
931
|
+
if (spans.length === 0)
|
|
932
|
+
return text;
|
|
933
|
+
let out = '';
|
|
934
|
+
let pos = 0;
|
|
935
|
+
for (const s of spans) {
|
|
936
|
+
out += text.slice(pos, s.from) + '***@';
|
|
937
|
+
pos = s.at + 1;
|
|
938
|
+
}
|
|
939
|
+
return out + text.slice(pos);
|
|
940
|
+
}
|
|
941
|
+
/** The spans of findBareUserinfoSpans for a source text, with the characters that stripControlChars removes read as
|
|
942
|
+
* a letter, which keeps every position and does not end a run or a label. */
|
|
943
|
+
export function bareUserinfoSpansOf(text) {
|
|
944
|
+
return findBareUserinfoSpans(text.replace(CONTROL_CHARS, (m) => 'a'.repeat(m.length)));
|
|
945
|
+
}
|
|
807
946
|
/** Masks user information, query values and fragments of every URL-like run in a piece of report text.
|
|
808
947
|
* maskParenUserinfo and maskAuthorityUserinfo run first, for the shapes the runs of RUN cannot see as one URL, and
|
|
809
|
-
*
|
|
810
|
-
* --format text report (0.2.16, found by an
|
|
948
|
+
* maskBareUserinfo for the name:secret@host shape without a scheme separator. stripControlChars runs last so a raw
|
|
949
|
+
* ANSI escape from a compared page or an argument cannot reach a plain --format text report (0.2.16, found by an
|
|
950
|
+
* outside review 2026-09-28). */
|
|
811
951
|
export function redactText(text) {
|
|
812
952
|
// The control characters go first as well as last: a vertical tab, a form feed, U+2028 or U+0085 inside the user
|
|
813
953
|
// information would otherwise end the authority for the masking and be removed afterwards, which left a credential
|
|
814
954
|
// that read as a whole URL.
|
|
815
|
-
return stripControlChars(rewriteUrlRuns(maskAuthorityUserinfo(maskParenUserinfo(stripControlChars(text)), true), maskHref));
|
|
955
|
+
return stripControlChars(rewriteUrlRuns(maskBareUserinfo(maskAuthorityUserinfo(maskParenUserinfo(stripControlChars(text)), true)), maskHref));
|
|
816
956
|
}
|
|
817
957
|
/**
|
|
818
958
|
* The text with the parts that maskHref hides taken out of every URL-like run: user information, query values
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const TOOL_NAME = "markdown-parity-check";
|
|
2
|
-
export declare const TOOL_VERSION = "0.2.
|
|
2
|
+
export declare const TOOL_VERSION = "0.2.40";
|
package/dist/src/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Cloudflare Worker as well as under Node.js. test/version.test.ts fails the build when these differ
|
|
3
3
|
// from package.json, which stays the version the release workflow publishes.
|
|
4
4
|
export const TOOL_NAME = 'markdown-parity-check';
|
|
5
|
-
export const TOOL_VERSION = '0.2.
|
|
5
|
+
export const TOOL_VERSION = '0.2.40';
|
package/package.json
CHANGED