-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add unicode character support for default avatars #33882
base: develop
Are you sure you want to change the base?
feat: Add unicode character support for default avatars #33882
Conversation
…characters allowed in the settings
…characters allowed in the settings
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Can someone please tell me... |
don't worry about it.. this is not required to merge the PR, but the tests are.. also, do you mind explaining your use case? what character do you want to have used on avatars? |
Thank you for your support. eg.) In both cases, we would like to be able to display anything that can pass the validation patterns specified in “UTF8_User_Names_Validation” and “UTF8_Channel_Names_Validation”, rather than being limited to alphanumeric characters. |
3741d4f
to
f4c92b9
Compare
Could you help me again?
I don't know why the error occurs. |
…bbbbb/Rocket.Chat into chore/change-avatar-initials
It seems to have succeeded except for “CI / deploy-preview (pull_request)”. @sampaiodiego |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR should be labeled as feat
, since it's changing a core feature. In this case you'll also need to add a changeset. It would be good to have a more descriptive title too, such as Add unicode character support for default avatars
or something similar.
Please refer to our docs on informantion on adding changesets and pull request tags.
Can you also please update the tests in utils.spec.ts
to contemplate these changes?
.toUpperCase(); | ||
const getFirstLetter = (name: string, regExp: RegExp) => { | ||
const pattern = regExp || defaultPattern; | ||
const sanitizedName = name.replace(/[&<>]/g, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use dompurify
to sanitize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed to use dompurify
.
return req.url.startsWith('/room') | ||
? (settings.get('UTF8_Channel_Names_Validation') as string) | ||
: (settings.get('UTF8_User_Names_Validation') as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be necessary. These settings validate username and room name when they are created, so roomOrUsername will be already respecting them. You'd also not need to check the URL in this case.
Was there a speicfic need to do this I might've missed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a futile consideration.
Changed to be concise and only perform sanitization process.
} | ||
|
||
const fontSize = viewSize / 1.6; | ||
|
||
return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${viewSize} ${viewSize}\">\n<rect width=\"100%\" height=\"100%\" fill=\"${color}\"/>\n<text x=\"50%\" y=\"50%\" dy=\"0.36em\" text-anchor=\"middle\" pointer-events=\"none\" fill=\"#ffffff\" font-family=\"'Helvetica', 'Arial', 'Lucida Grande', 'sans-serif'\" font-size="${fontSize}">\n${initials}\n</text>\n</svg>`; | ||
return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${viewSize} ${viewSize}\">\n<rect width=\"100%\" height=\"100%\" fill=\"${color}\"/>\n<text x=\"50%\" y=\"50%\" dy=\"0.36em\" text-anchor=\"middle\" pointer-events=\"none\" fill=\"#ffffff\" font-family=\"'Helvetica', 'Arial Unicode MS', 'Noto Sans', 'Segoe UI', 'Lucida Grande', 'sans-serif'\" font-size="${fontSize}">\n${initials}\n</text>\n</svg>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how we handle typeface changes like these. I'll raise the concern internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also unnecessary.
I honestly can't remember why the change was made. I have reverted it back.
…characters allowed in the settings
…characters allowed in the settings
…bbbbb/Rocket.Chat into chore/change-avatar-initials
…characters allowed in the settings
…bbbbb/Rocket.Chat into chore/change-avatar-initials
This PR allows non-alphanumeric characters to appear as the default avatar for users and channels. (but only for strings allowed in the settings)
Proposed changes (including videos or screenshots)
Issue(s)
#33602
Steps to test or reproduce
Further comments