Skip to content
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

Allow pool metadata to display UTF-8 emojis #10189

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ArthurHoeke
Copy link

Currently Polkadot-js allows for UTF-8 emojis to be displayed on both the validators page and address identities. However, the pools page currently strips any non-standard characters from pool names.

For consistency this pull request adjusts the transformName regex to allow for UTF-8 emojis, as is also the case on staking.polkadot.network/#/pools.

@jacogr
Copy link
Member

jacogr commented Jan 17, 2024

Identities -

  • don't show emojis when the identity has not been approved
  • do show emojis when the identity is deemed at least reasonable by a registrar

aka not by default until it is deemed "non-spam" and viable.

There is no built-in spam/frustration filter on these specific user inputs, hence the filter applied here.

@ArthurHoeke
Copy link
Author

ArthurHoeke commented Jan 17, 2024

Identities -

  • don't show emojis when the identity has not been approved
  • do show emojis when the identity is deemed at least reasonable by a registrar

aka not by default until it is deemed "non-spam" and viable.

There is no built-in spam/frustration filter on these specific user inputs, hence the filter applied here.

How about allowing say up to 4 emoji's to prevent spam and maybe filtering out any unwanted ones? As of right now a bad actor could already put anything they'd want in the pool metadata, don't think there are that many potentially bad emojis out there.

function transformName(input: string): string {
  const naughtyEmojis = ['🔫','💩','☠️','🍆'];

  let sanitizedInput = input.replace(new RegExp(naughtyEmojis.join('|'), 'g'), '');

  const emojiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF]|[^\x20-\x7E\uD83C-\uDBFF\uDC00-\uDFFF])/g;
  const emojis = sanitizedInput.match(emojiRegex) || [];
  const limitedEmojis = emojis.slice(0, 4);

  emojis.forEach((emoji, index) => {
    sanitizedInput = sanitizedInput.replace(emoji, index < 4 ? limitedEmojis[index] : '');
  });

  return sanitizedInput;
}

Also taking into account that a bad actor could lose their initial minimum bond of 500 DOT.

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.

2 participants