Skip to content

Commit 5c02f9e

Browse files
authored
Fix MDX lint URL false positives in prose (#79)
**Why** Connector docs can contain ordinary prose such as “To sync (read) data:”. The MDX validator was scanning all text nodes for dangerous URL schemes, so that prose failed as if it were an actual data URL. Connector repos should not need wording-only PRs to work around that false positive. **What this changes** Narrows dangerous URL checks to URL-bearing markdown nodes and JSX attributes. Plain text is no longer scanned as a URL, while links, images, definitions, href/src/action attributes, and encoded dangerous URL schemes remain blocked. Adds a regression test for the Sentry-style Step content that triggered the failure. **Validation** - npm test --prefix tools/mdx-lint - patched validator accepts the current baton-sentry docs/connector.mdx - patched validator still rejects an explicit data: markdown link - git diff --check **Rollout** After merge, publish the updated reusable workflow ref used by connector repos. They currently call ConductorOne/github-workflows at v4, so v4 must point at this fix before baton-sentry main stops using the old validator.
1 parent 0e8e52d commit 5c02f9e

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

tools/mdx-lint/mdx-lint.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ function validateTree(tree) {
152152
case "definition":
153153
validateUrlNode(node);
154154
break;
155-
case "text":
156-
if (containsDangerousUrl(node.value)) {
157-
fail(node, "contains a dangerous URL scheme");
158-
}
159-
break;
160155
}
161156
});
162157
}

tools/mdx-lint/mdx-lint.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ Read the public setup guide at https://example.com/docs.
4444
`);
4545
});
4646

47+
it("allows dangerous URL scheme names in plain prose", async () => {
48+
await expectValid(`<Steps>
49+
<Step>
50+
In the permissions section, choose the relevant permissions:
51+
52+
To sync (read) data:
53+
54+
- Project: Read
55+
</Step>
56+
</Steps>
57+
`);
58+
});
59+
4760
it("rejects unknown JSX components", async () => {
4861
await expectInvalid("<Unknown />\n", /disallowed JSX component "Unknown"/);
4962
});

0 commit comments

Comments
 (0)