Skip to content

Commit 84ca305

Browse files
committed
[pat] validate name
1 parent f89093d commit 84ca305

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/dashboard/src/settings/PersonalAccessTokens.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { InputWithCopy } from "../components/InputWithCopy";
2121
import { copyToClipboard } from "../utils";
2222
import TokenEntry from "./TokenEntry";
2323

24+
const personalAccessTokenNameRegex = /^[a-zA-Z0-9-_ ]{3,63}$/;
25+
2426
function PersonalAccessTokens() {
2527
const { enablePersonalAccessTokens } = useContext(FeatureFlagContext);
2628

@@ -150,6 +152,10 @@ export function PersonalAccessTokenCreateView() {
150152
if (change.expirationDays) {
151153
change.expirationDate = new Date(Date.now() + change.expirationDays * 24 * 60 * 60 * 1000);
152154
}
155+
if (change.name) {
156+
if (!personalAccessTokenNameRegex.test(change.name)) {
157+
}
158+
}
153159
setErrorMsg("");
154160
setValue({ ...value, ...change });
155161
};

0 commit comments

Comments
 (0)