Conversation
|
/crush_fast AI review started. |
Advanced AI Review
Click to expand reviewCode Review: Non-English Channel Name SupportIssue 1:
|
group-income
|
||||||||||||||||||||||||||||
| Project |
group-income
|
| Branch Review |
sebin/task/#3064-non-english-channel-name-issue
|
| Run status |
|
| Run duration | 14m 25s |
| Commit |
|
| Committer | Sebin Song |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
10
|
|
|
0
|
|
|
117
|
| View all changes introduced in this branch ↗︎ | |
|
/crush_fast AI review started. |
Advanced AI Review
Click to expand reviewLet me investigate a few more things before giving my review.Now let me check one more thing about how the 1. 🟡
|
…n-english-channel-name-issue
|
/crush_fast {{openrouter, google/gemini-3.1-pro-preview, google/gemini-3-flash-preview}} AI review started. |
Advanced AI Review
Click to expand review1. 🔴 Unicode Normalization prevents homoglyph spoofing (Security)
The introduction of Unicode classes ( Additionally, using NFKC prevents visual width issues with full-width alphanumeric variants such as full-width digits (like In export const sanitizeChannelName = (name: string): string => {
return name.replace(/\s/g, '-') // Replace all whitespace with '-'
.normalize('NFKC') // Normalize to prevent visual spoofing
.toLowerCase() // Convert to lowercase
/*
The regex below removes everything except:
\p{L} - Any letter from any language
\p{M} - Any combining mark
\p{Nd} - Any digit numbers
'-' - The hyphen (separator)
Reference: Unicode character class escape -
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape
*/
.replace(/[^\p{L}\p{M}\p{Nd}-]/gu, '')
}To enforce this safely on the contract level to secure against decentralized API interactions originating outside of the frontend client, introduce a normalization check in const nameValidationMap: {[string]: Function} = {
[L('Chatroom name must be normalized')]: (v: string): boolean => v !== v.normalize('NFKC'),
[L('Chatroom name cannot contain white-space')]: (v: string): boolean => /\s/.test(v),
[L('Chatroom name cannot contain capital letters')]: (v: string): boolean => /\p{Lu}/u.test(v),
[L('Chatroom name cannot contain punctuation or special characters except hyphens')]: (v: string): boolean => /[^\p{L}\p{M}\p{Nd}-]/u.test(v)
}I don't see why 2. 🟡 Reconsider how uppercase letters are detected
In const nameValidationMap: {[string]: Function} = {
[L('Chatroom name cannot contain white-space')]: (v: string): boolean => /\s/.test(v),
[L('Chatroom name cannot contain capital letters')]: (v: string): boolean => v !== v.toLowerCase(),
[L('Chatroom name cannot contain punctuation or special characters except hyphens')]: (v: string): boolean => /[^\p{L}\p{M}\p{Nd}-]/u.test(v)
}
3. ⚪ Null-safety and simplifications for the duplicate names check
In It is also more conventional to case-fold downward using [L('Duplicate channel name')]: (name, siblings) => {
if (!name) return true
const checkName = name.normalize('NFKC').toLowerCase()
for (const existingName of siblings.existingNames) {
if (checkName === (existingName || '').normalize('NFKC').toLowerCase()) {
return false
}
}
return true
}name being potentially being Review generated using |
|
The PR is ready. |
closes #3064
channel-name-fix.mp4