Skip to content

feat: improve username sanitization in profiling example#2

Merged
Dongnyoung merged 1 commit intomainfrom
fix/username-sanitization-1
Jun 15, 2025
Merged

feat: improve username sanitization in profiling example#2
Dongnyoung merged 1 commit intomainfrom
fix/username-sanitization-1

Conversation

@Dongnyoung
Copy link
Copy Markdown
Owner

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: nodejs#7867

Description

Validation

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

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: nodejs#7867

Signed-off-by: DongNyoung Lee <121621378+Dongnyoung@users.noreply.github.com>
@Dongnyoung Dongnyoung merged commit a3e1ef3 into main Jun 15, 2025
@Dongnyoung Dongnyoung deleted the fix/username-sanitization-1 branch June 15, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant