Skip to content

Commit d44b63e

Browse files
committed
Perform case-insensitive username checking
Fixes #34.
1 parent 68307e6 commit d44b63e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

__tests__/__snapshots__/get-user-status.js.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ Object {
1111
}
1212
`;
1313

14+
exports[`Individual exists, but their username is spelled with a different case 1`] = `
15+
Object {
16+
"context": "Participation",
17+
"description": "@JANEdoetw has signed up to participate as an individual",
18+
"isNothing": false,
19+
"longDescription": "@JANEdoetw has signed up to participate as an individual. All is well; contribute at will!",
20+
"state": "success",
21+
"target_url": "https://participate.whatwg.org/agreement-status?user=JANEdoetw&repo=console",
22+
}
23+
`;
24+
1425
exports[`Individual, participating in all workstreams, unverified 1`] = `
1526
Object {
1627
"context": "Participation",

__tests__/get-user-status.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,10 @@ test("Individuals exist, but the user is not one of them; it is an XSS attempt",
211211
]);
212212
expect(await getUserStatus("<script>alert(1);</script>", "console")).toMatchSnapshot();
213213
});
214+
215+
216+
test("Individual exists, but their username is spelled with a different case", async () => {
217+
mockData.set("individual-public", [individualData(["console"], true, { id: "janeDOEtw" })]);
218+
219+
expect(await getUserStatus("JANEdoetw", "console")).toMatchSnapshot();
220+
});

lib/get-user-status.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module.exports = async (submitterGitHubID, repoName) => {
1515
]);
1616

1717
for (const individual of individualsData.content) {
18-
if (individual.info.gitHubID === submitterGitHubID) {
18+
// Using .toLowerCase() is safe because GitHub usernames only allow ASCII.
19+
if (individual.info.gitHubID.toLowerCase() === submitterGitHubID.toLowerCase()) {
1920
if (individual.verified) {
2021
if (individual.workstreams === "all" || individual.workstreams.includes(repoName)) {
2122
return statusIndividual(submitterGitHubID, repoName);

0 commit comments

Comments
 (0)