Skip to content

Commit 616d437

Browse files
authored
feat: improve username sanitization in profiling example (#7868)
Hello, This commit updates the username sanitization logic in the profiling example code to allow only alphanumeric characters. The original pattern (/[!@#$%^&*]/g) was limited and could lead to inconsistent behavior depending on input. Changed: - From: username = username.replace(/[!@#$%^&*]/g, '') - To: username = username.replace(/[^a-zA-Z0-9]/g, '') This change makes the input handling cleaner and more appropriate for educational purposes, aligning better with common sanitization practices. Relates to: #7867 Signed-off-by: DongNyoung Lee <[email protected]>
1 parent 3e5b666 commit 616d437

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/site/pages/en/learn/getting-started/profiling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ app.get('/newUser', (req, res) => {
4141
let username = req.query.username || '';
4242
const password = req.query.password || '';
4343

44-
username = username.replace(/[!@#$%^&*]/g, '');
44+
username = username.replace(/[^a-zA-Z0-9]/g, '');
4545

4646
if (!username || !password || users[username]) {
4747
return res.sendStatus(400);
@@ -63,7 +63,7 @@ app.get('/auth', (req, res) => {
6363
let username = req.query.username || '';
6464
const password = req.query.password || '';
6565

66-
username = username.replace(/[!@#$%^&*]/g, '');
66+
username = username.replace(/[^a-zA-Z0-9]/g, '');
6767

6868
if (!username || !password || !users[username]) {
6969
return res.sendStatus(400);
@@ -228,7 +228,7 @@ app.get('/auth', (req, res) => {
228228
let username = req.query.username || '';
229229
const password = req.query.password || '';
230230

231-
username = username.replace(/[!@#$%^&*]/g, '');
231+
username = username.replace(/[^a-zA-Z0-9]/g, '');
232232

233233
if (!username || !password || !users[username]) {
234234
return res.sendStatus(400);

0 commit comments

Comments
 (0)